Index: test/cctest/test-wasm-relocation-disasm-arm.cc |
diff --git a/test/cctest/test-symbols.cc b/test/cctest/test-wasm-relocation-disasm-arm.cc |
similarity index 51% |
copy from test/cctest/test-symbols.cc |
copy to test/cctest/test-wasm-relocation-disasm-arm.cc |
index 1024a27edfd88cd0c5769f0b86d56b0a7f8475b2..1077bde6fe50a5205470048f2c0f095f14804755 100644 |
--- a/test/cctest/test-symbols.cc |
+++ b/test/cctest/test-wasm-relocation-disasm-arm.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2013 the V8 project authors. All rights reserved. |
+// Copyright 2016 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -25,52 +25,75 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Check that we can traverse very deep stacks of ConsStrings using |
-// StringCharacterStram. Check that Get(int) works on very deep stacks |
-// of ConsStrings. These operations may not be very fast, but they |
-// should be possible without getting errors due to too deep recursion. |
+#include <iostream> // NOLINT(readability/streams) |
#include "src/v8.h" |
+#include "test/cctest/cctest.h" |
-#include "src/objects.h" |
+#include "src/arm/assembler-arm-inl.h" |
+#include "src/arm/simulator-arm.h" |
+#include "src/disassembler.h" |
+#include "src/factory.h" |
#include "src/ostreams.h" |
-#include "test/cctest/cctest.h" |
+#include "test/cctest/compiler/c-signature.h" |
+#include "test/cctest/compiler/call-tester.h" |
+using namespace v8::base; |
using namespace v8::internal; |
+using namespace v8::internal::compiler; |
+#define __ assm. |
-TEST(Create) { |
+static int32_t DummyStaticFunction(Object* result) { return 1; } |
+ |
+TEST(WasmRelocationArm) { |
CcTest::InitializeVM(); |
Isolate* isolate = CcTest::i_isolate(); |
HandleScope scope(isolate); |
+ v8::internal::byte buffer[4096]; |
+ DummyStaticFunction(NULL); |
+ int32_t imm = 1234567; |
+ |
+ Assembler assm(isolate, buffer, sizeof buffer); |
- const int kNumSymbols = 30; |
- Handle<Symbol> symbols[kNumSymbols]; |
+ __ mov(r0, Operand(imm, RelocInfo::WASM_MEMORY_REFERENCE)); |
+ __ mov(pc, Operand(lr)); |
+ CodeDesc desc; |
+ assm.GetCode(&desc); |
+ Handle<Code> code = isolate->factory()->NewCode( |
+ desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
+ |
+ CSignature0<int32_t> csig; |
+ CodeRunner<int32_t> runnable(isolate, code, &csig); |
+ int32_t ret_value = runnable.Call(); |
+ CHECK_EQ(ret_value, imm); |
+ |
+#ifdef DEBUG |
OFStream os(stdout); |
- for (int i = 0; i < kNumSymbols; ++i) { |
- symbols[i] = isolate->factory()->NewSymbol(); |
- CHECK(symbols[i]->IsName()); |
- CHECK(symbols[i]->IsSymbol()); |
- CHECK(symbols[i]->HasHashCode()); |
- CHECK_GT(symbols[i]->Hash(), 0u); |
- os << Brief(*symbols[i]) << "\n"; |
-#if OBJECT_PRINT |
- symbols[i]->Print(os); |
-#endif |
-#if VERIFY_HEAP |
- symbols[i]->ObjectVerify(); |
+ code->Print(os); |
+ ::printf("f() = %d\n\n", ret_value); |
#endif |
- } |
- |
- CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
- CcTest::heap()->CollectAllGarbage(); |
+ size_t offset = 1234; |
- // All symbols should be distinct. |
- for (int i = 0; i < kNumSymbols; ++i) { |
- CHECK(symbols[i]->SameValue(*symbols[i])); |
- for (int j = i + 1; j < kNumSymbols; ++j) { |
- CHECK(!symbols[i]->SameValue(*symbols[j])); |
+ // Relocating references by offset |
+ int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE); |
+ for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
+ RelocInfo::Mode mode = it.rinfo()->rmode(); |
+ if (RelocInfo::IsWasmMemoryReference(mode)) { |
+ it.rinfo()->update_wasm_memory_reference( |
+ it.rinfo()->wasm_memory_reference() + offset, SKIP_ICACHE_FLUSH); |
} |
} |
+ |
+ // Call into relocated code object |
+ ret_value = runnable.Call(); |
+ CHECK_EQ((imm + offset), ret_value); |
+ |
+#ifdef DEBUG |
+ code->Print(os); |
+ ::printf("f() = %d\n\n", ret_value); |
+#endif |
} |
+ |
+#undef __ |