OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { | 66 void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { |
67 GET_STACK_POINTER(); | 67 GET_STACK_POINTER(); |
68 args.GetReturnValue().Set(v8_num(sp_addr)); | 68 args.GetReturnValue().Set(v8_num(sp_addr)); |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 TEST(StackAlignment) { | 72 TEST(StackAlignment) { |
73 v8::Isolate* isolate = CcTest::isolate(); | 73 v8::Isolate* isolate = CcTest::isolate(); |
74 v8::HandleScope handle_scope(isolate); | 74 v8::HandleScope handle_scope(isolate); |
75 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); | 75 v8::Handle<v8::ObjectTemplate> global_template = |
| 76 v8::ObjectTemplate::New(isolate); |
76 global_template->Set(v8_str("get_stack_pointer"), | 77 global_template->Set(v8_str("get_stack_pointer"), |
77 v8::FunctionTemplate::New(isolate, GetStackPointer)); | 78 v8::FunctionTemplate::New(isolate, GetStackPointer)); |
78 | 79 |
79 LocalContext env(NULL, global_template); | 80 LocalContext env(NULL, global_template); |
80 CompileRun( | 81 CompileRun( |
81 "function foo() {" | 82 "function foo() {" |
82 " return get_stack_pointer();" | 83 " return get_stack_pointer();" |
83 "}"); | 84 "}"); |
84 | 85 |
85 v8::Local<v8::Object> global_object = env->Global(); | 86 v8::Local<v8::Object> global_object = env->Global(); |
86 v8::Local<v8::Function> foo = | 87 v8::Local<v8::Function> foo = |
87 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); | 88 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); |
88 | 89 |
89 v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); | 90 v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); |
90 CHECK_EQ(0, result->Int32Value() % OS::ActivationFrameAlignment()); | 91 CHECK_EQ(0, result->Int32Value() % OS::ActivationFrameAlignment()); |
91 } | 92 } |
92 | 93 |
93 #undef GET_STACK_POINTERS | 94 #undef GET_STACK_POINTERS |
94 #undef ASM | 95 #undef ASM |
95 #endif // __GNUC__ | 96 #endif // __GNUC__ |
OLD | NEW |