[wasm] fix TestInterruptLoop for Big Endian platform
Using Read/WriteLittleEndianValue method to access native memory. This will perform byte reversal depending on the endianness of the patform. Testcase was added in CL: https://codereview.chromium.org/2405293002 R=ahaas@chromium.org, titzer@chromium.org BUG= LOG=N Review-Url: https://codereview.chromium.org/2479043003 Cr-Commit-Position: refs/heads/master@{#40815}
This commit is contained in:
parent
57f8e38ecb
commit
e1a57a03b2
@ -419,13 +419,17 @@ class InterruptThread : public v8::base::Thread {
|
||||
static void OnInterrupt(v8::Isolate* isolate, void* data) {
|
||||
int32_t* m = reinterpret_cast<int32_t*>(data);
|
||||
// Set the interrupt location to 0 to break the loop in {TestInterruptLoop}.
|
||||
m[interrupt_location_] = interrupt_value_;
|
||||
int32_t* ptr = &m[interrupt_location_];
|
||||
WriteLittleEndianValue<int32_t>(ptr, interrupt_value_);
|
||||
}
|
||||
|
||||
virtual void Run() {
|
||||
// Wait for the main thread to write the signal value.
|
||||
while (memory_[0] != signal_value_) {
|
||||
}
|
||||
int32_t val = 0;
|
||||
do {
|
||||
val = memory_[0];
|
||||
val = ReadLittleEndianValue<int32_t>(&val);
|
||||
} while (val != signal_value_);
|
||||
isolate_->RequestInterrupt(&OnInterrupt, const_cast<int32_t*>(memory_));
|
||||
}
|
||||
|
||||
@ -489,8 +493,9 @@ TEST(TestInterruptLoop) {
|
||||
thread.Start();
|
||||
testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr,
|
||||
ModuleOrigin::kWasmOrigin);
|
||||
int32_t val = memory_array[InterruptThread::interrupt_location_];
|
||||
CHECK_EQ(InterruptThread::interrupt_value_,
|
||||
memory_array[InterruptThread::interrupt_location_]);
|
||||
ReadLittleEndianValue<int32_t>(&val));
|
||||
}
|
||||
|
||||
TEST(Run_WasmModule_GrowMemoryInIf) {
|
||||
|
Loading…
Reference in New Issue
Block a user