Commit e1a57a03 authored by bjaideep's avatar bjaideep Committed by Commit bot

[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}
parent 57f8e38e
...@@ -419,13 +419,17 @@ class InterruptThread : public v8::base::Thread { ...@@ -419,13 +419,17 @@ class InterruptThread : public v8::base::Thread {
static void OnInterrupt(v8::Isolate* isolate, void* data) { static void OnInterrupt(v8::Isolate* isolate, void* data) {
int32_t* m = reinterpret_cast<int32_t*>(data); int32_t* m = reinterpret_cast<int32_t*>(data);
// Set the interrupt location to 0 to break the loop in {TestInterruptLoop}. // 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() { virtual void Run() {
// Wait for the main thread to write the signal value. // 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_)); isolate_->RequestInterrupt(&OnInterrupt, const_cast<int32_t*>(memory_));
} }
...@@ -489,8 +493,9 @@ TEST(TestInterruptLoop) { ...@@ -489,8 +493,9 @@ TEST(TestInterruptLoop) {
thread.Start(); thread.Start();
testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr, testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr,
ModuleOrigin::kWasmOrigin); ModuleOrigin::kWasmOrigin);
int32_t val = memory_array[InterruptThread::interrupt_location_];
CHECK_EQ(InterruptThread::interrupt_value_, CHECK_EQ(InterruptThread::interrupt_value_,
memory_array[InterruptThread::interrupt_location_]); ReadLittleEndianValue<int32_t>(&val));
} }
TEST(Run_WasmModule_GrowMemoryInIf) { TEST(Run_WasmModule_GrowMemoryInIf) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment