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 // TODO(mythria): Remove this define after this flag is turned on globally |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 |
5 #include <stdint.h> | 8 #include <stdint.h> |
6 #include "src/base/build_config.h" | 9 #include "src/base/build_config.h" |
7 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
8 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
9 | 12 |
10 #ifdef V8_CC_GNU | 13 #ifdef V8_CC_GNU |
11 | 14 |
12 static uintptr_t sp_addr = 0; | 15 static uintptr_t sp_addr = 0; |
13 | 16 |
14 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { | 17 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
(...skipping 18 matching lines...) Expand all Loading... |
33 #endif | 36 #endif |
34 | 37 |
35 args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( | 38 args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( |
36 args.GetIsolate(), static_cast<uint32_t>(sp_addr))); | 39 args.GetIsolate(), static_cast<uint32_t>(sp_addr))); |
37 } | 40 } |
38 | 41 |
39 | 42 |
40 TEST(StackAlignment) { | 43 TEST(StackAlignment) { |
41 v8::Isolate* isolate = CcTest::isolate(); | 44 v8::Isolate* isolate = CcTest::isolate(); |
42 v8::HandleScope handle_scope(isolate); | 45 v8::HandleScope handle_scope(isolate); |
43 v8::Handle<v8::ObjectTemplate> global_template = | 46 v8::Local<v8::ObjectTemplate> global_template = |
44 v8::ObjectTemplate::New(isolate); | 47 v8::ObjectTemplate::New(isolate); |
45 global_template->Set(v8_str("get_stack_pointer"), | 48 global_template->Set(v8_str("get_stack_pointer"), |
46 v8::FunctionTemplate::New(isolate, GetStackPointer)); | 49 v8::FunctionTemplate::New(isolate, GetStackPointer)); |
47 | 50 |
48 LocalContext env(NULL, global_template); | 51 LocalContext env(NULL, global_template); |
49 CompileRun( | 52 CompileRun( |
50 "function foo() {" | 53 "function foo() {" |
51 " return get_stack_pointer();" | 54 " return get_stack_pointer();" |
52 "}"); | 55 "}"); |
53 | 56 |
54 v8::Local<v8::Object> global_object = env->Global(); | 57 v8::Local<v8::Object> global_object = env->Global(); |
55 v8::Local<v8::Function> foo = | 58 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast( |
56 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); | 59 global_object->Get(isolate->GetCurrentContext(), v8_str("foo")) |
| 60 .ToLocalChecked()); |
57 | 61 |
58 v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); | 62 v8::Local<v8::Value> result = |
59 CHECK_EQ(0u, | 63 foo->Call(isolate->GetCurrentContext(), global_object, 0, NULL) |
60 result->Uint32Value() % v8::base::OS::ActivationFrameAlignment()); | 64 .ToLocalChecked(); |
| 65 CHECK_EQ(0u, result->Uint32Value(isolate->GetCurrentContext()).FromJust() % |
| 66 v8::base::OS::ActivationFrameAlignment()); |
61 } | 67 } |
62 | 68 |
63 #endif // V8_CC_GNU | 69 #endif // V8_CC_GNU |
OLD | NEW |