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