OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "include/v8stdint.h" | 5 #include "include/v8stdint.h" |
6 #include "src/base/build_config.h" | 6 #include "src/base/build_config.h" |
7 #include "src/base/platform/platform.h" | 7 #include "src/base/platform/platform.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 | 9 |
10 #ifdef V8_CC_GNU | 10 #ifdef V8_CC_GNU |
11 | 11 |
12 static uintptr_t sp_addr = 0; | 12 static uintptr_t sp_addr = 0; |
13 | 13 |
14 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { | 14 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
15 #if V8_HOST_ARCH_X64 | 15 #if V8_HOST_ARCH_X64 |
16 __asm__ __volatile__("mov %%rsp, %0" : "=g"(sp_addr)); | 16 __asm__ __volatile__("mov %%rsp, %0" : "=g"(sp_addr)); |
17 #elif V8_HOST_ARCH_IA32 | 17 #elif V8_HOST_ARCH_IA32 |
18 __asm__ __volatile__("mov %%esp, %0" : "=g"(sp_addr)); | 18 __asm__ __volatile__("mov %%esp, %0" : "=g"(sp_addr)); |
19 #elif V8_HOST_ARCH_ARM | 19 #elif V8_HOST_ARCH_ARM |
20 __asm__ __volatile__("str %%sp, %0" : "=g"(sp_addr)); | 20 __asm__ __volatile__("str %%sp, %0" : "=g"(sp_addr)); |
21 #elif V8_HOST_ARCH_ARM64 | 21 #elif V8_HOST_ARCH_ARM64 |
22 __asm__ __volatile__("mov x16, sp; str x16, %0" : "=g"(sp_addr)); | 22 __asm__ __volatile__("mov x16, sp; str x16, %0" : "=g"(sp_addr)); |
23 #elif V8_HOST_ARCH_MIPS | 23 #elif V8_HOST_ARCH_MIPS |
24 __asm__ __volatile__("sw $sp, %0" : "=g"(sp_addr)); | 24 __asm__ __volatile__("sw $sp, %0" : "=g"(sp_addr)); |
| 25 #elif V8_HOST_ARCH_MIPS64 |
| 26 __asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr)); |
25 #else | 27 #else |
26 #error Host architecture was not detected as supported by v8 | 28 #error Host architecture was not detected as supported by v8 |
27 #endif | 29 #endif |
28 | 30 |
29 args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( | 31 args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( |
30 args.GetIsolate(), static_cast<uint32_t>(sp_addr))); | 32 args.GetIsolate(), static_cast<uint32_t>(sp_addr))); |
31 } | 33 } |
32 | 34 |
33 | 35 |
34 TEST(StackAlignment) { | 36 TEST(StackAlignment) { |
(...skipping 12 matching lines...) Expand all Loading... |
47 | 49 |
48 v8::Local<v8::Object> global_object = env->Global(); | 50 v8::Local<v8::Object> global_object = env->Global(); |
49 v8::Local<v8::Function> foo = | 51 v8::Local<v8::Function> foo = |
50 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); | 52 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); |
51 | 53 |
52 v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); | 54 v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); |
53 CHECK_EQ(0, result->Uint32Value() % v8::base::OS::ActivationFrameAlignment()); | 55 CHECK_EQ(0, result->Uint32Value() % v8::base::OS::ActivationFrameAlignment()); |
54 } | 56 } |
55 | 57 |
56 #endif // V8_CC_GNU | 58 #endif // V8_CC_GNU |
OLD | NEW |