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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 "})()"; | 235 "})()"; |
236 | 236 |
237 // Disable context specialization. | 237 // Disable context specialization. |
238 FunctionTester T(script); | 238 FunctionTester T(script); |
239 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 239 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
240 v8::Context::Scope scope(context); | 240 v8::Context::Scope scope(context); |
241 v8::Local<v8::Value> value = CompileRun(script); | 241 v8::Local<v8::Value> value = CompileRun(script); |
242 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 242 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
243 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 243 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
244 jsfun->set_code(T.function->code()); | 244 jsfun->set_code(T.function->code()); |
| 245 jsfun->set_shared(T.function->shared()); |
245 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | 246 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); |
246 CompileRun("var x = 24;"); | 247 CompileRun("var x = 24;"); |
247 ExpectInt32("foo();", 24); | 248 ExpectInt32("foo();", 24); |
248 } | 249 } |
249 | 250 |
250 | 251 |
251 TEST(BuiltinLoadedFromActivation) { | 252 TEST(BuiltinLoadedFromActivation) { |
252 const char* script = | 253 const char* script = |
253 "var x = 42;" | 254 "var x = 42;" |
254 "(function() {" | 255 "(function() {" |
255 " return function () { return this; };" | 256 " return function () { return this; };" |
256 "})()"; | 257 "})()"; |
257 | 258 |
258 // Disable context specialization. | 259 // Disable context specialization. |
259 FunctionTester T(script); | 260 FunctionTester T(script); |
260 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); | 261 v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); |
261 v8::Context::Scope scope(context); | 262 v8::Context::Scope scope(context); |
262 v8::Local<v8::Value> value = CompileRun(script); | 263 v8::Local<v8::Value> value = CompileRun(script); |
263 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); | 264 i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); |
264 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); | 265 i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); |
265 jsfun->set_code(T.function->code()); | 266 jsfun->set_code(T.function->code()); |
| 267 jsfun->set_shared(T.function->shared()); |
266 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); | 268 context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); |
267 CompileRun("var x = 24;"); | 269 CompileRun("var x = 24;"); |
268 ExpectObject("foo()", context->Global()); | 270 ExpectObject("foo()", context->Global()); |
269 } | 271 } |
OLD | NEW |