OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 using namespace v8::internal; | 9 using namespace v8::internal; |
10 using namespace v8::internal::compiler; | 10 using namespace v8::internal::compiler; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 // Disable context specialization. | 209 // Disable context specialization. |
210 FunctionTester T(script); | 210 FunctionTester T(script); |
211 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 211 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
212 v8::Context::Scope scope(context); | 212 v8::Context::Scope scope(context); |
213 v8::Local<v8::Value> value = CompileRun(script); | 213 v8::Local<v8::Value> value = CompileRun(script); |
214 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 214 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
215 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 215 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
216 jsfun->set_code(T.function->code()); | 216 jsfun->set_code(T.function->code()); |
217 jsfun->set_shared(T.function->shared()); | 217 jsfun->set_shared(T.function->shared()); |
218 context->Global()->Set(v8_str("foo"), v8::Utils::FunctionToLocal(jsfun)); | 218 context->Global()->Set(v8_str("foo"), v8::Utils::CallableToLocal(jsfun)); |
219 CompileRun("var x = 24;"); | 219 CompileRun("var x = 24;"); |
220 ExpectInt32("foo();", 24); | 220 ExpectInt32("foo();", 24); |
221 } | 221 } |
222 | 222 |
223 | 223 |
224 TEST(BuiltinLoadedFromActivation) { | 224 TEST(BuiltinLoadedFromActivation) { |
225 const char* script = | 225 const char* script = |
226 "var x = 42;" | 226 "var x = 42;" |
227 "(function() {" | 227 "(function() {" |
228 " return function () { return this; };" | 228 " return function () { return this; };" |
229 "})()"; | 229 "})()"; |
230 | 230 |
231 // Disable context specialization. | 231 // Disable context specialization. |
232 FunctionTester T(script); | 232 FunctionTester T(script); |
233 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 233 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
234 v8::Context::Scope scope(context); | 234 v8::Context::Scope scope(context); |
235 v8::Local<v8::Value> value = CompileRun(script); | 235 v8::Local<v8::Value> value = CompileRun(script); |
236 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 236 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
237 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 237 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
238 jsfun->set_code(T.function->code()); | 238 jsfun->set_code(T.function->code()); |
239 jsfun->set_shared(T.function->shared()); | 239 jsfun->set_shared(T.function->shared()); |
240 context->Global()->Set(v8_str("foo"), v8::Utils::FunctionToLocal(jsfun)); | 240 context->Global()->Set(v8_str("foo"), v8::Utils::CallableToLocal(jsfun)); |
241 CompileRun("var x = 24;"); | 241 CompileRun("var x = 24;"); |
242 ExpectObject("foo()", context->Global()); | 242 ExpectObject("foo()", context->Global()); |
243 } | 243 } |
OLD | NEW |