Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: test/cctest/compiler/test-run-jscalls.cc

Issue 474633003: Load global object and builtins from activation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Load global object and builtins from activation. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 227
228 TEST(ReceiverPatching) { 228 TEST(ReceiverPatching) {
229 // TODO(turbofan): Note that this test only checks that the function prologue 229 // TODO(turbofan): Note that this test only checks that the function prologue
230 // patches an undefined receiver to the global receiver. If this starts to 230 // patches an undefined receiver to the global receiver. If this starts to
231 // fail once we fix the calling protocol, just remove this test. 231 // fail once we fix the calling protocol, just remove this test.
232 FunctionTester T("(function(a) { return this; })"); 232 FunctionTester T("(function(a) { return this; })");
233 Handle<JSObject> g(T.function->context()->global_object()->global_proxy()); 233 Handle<JSObject> g(T.function->context()->global_object()->global_proxy());
234 T.CheckCall(g, T.undefined()); 234 T.CheckCall(g, T.undefined());
235 } 235 }
236
237
238 THREADED_TEST(ContextLoadedFromActivation) {
239 i::FLAG_turbo_filter = "*";
240 i::FLAG_always_opt = true;
241 i::FLAG_context_specialization = false;
242
243 const char* script =
244 "var x = 42;"
245 "(function() {"
246 " return function () { return x };"
247 "})()";
248
249 v8::Isolate* isolate = CcTest::isolate();
250 v8::HandleScope outer(isolate);
251 v8::Local<v8::Value> fun;
252 {
253 v8::Local<v8::Context> env = v8::Context::New(isolate);
254 env->Enter();
255 CompileRun("var x = 42;");
256 fun = CompileRun(script);
257 env->Global()->Set(v8_str("foo"), fun);
258 ExpectInt32("foo();", 42);
259 env->Exit();
260 }
261
262 {
263 v8::Local<v8::Context> env = v8::Context::New(isolate);
264 env->Enter();
265 v8::Local<v8::Value> fun2 = CompileRun(script);
266 i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun);
267 i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun);
268 i::Handle<i::Object> oifun2 = v8::Utils::OpenHandle(*fun2);
269 i::Handle<i::JSFunction> ifun2 = Handle<JSFunction>::cast(oifun2);
270 ifun2->set_code(ifun->code());
271 env->Global()->Set(v8_str("foo"), fun2);
272 CompileRun("var x = 24;");
273 ExpectInt32("foo();", 24);
274 env->Exit();
275 }
276 }
277
278
279 THREADED_TEST(BuiltinLoadedFromActivation) {
280 i::FLAG_turbo_filter = "*";
281 i::FLAG_always_opt = true;
282 i::FLAG_context_specialization = false;
283
284 const char* script =
285 "var x = 42;"
286 "(function() {"
287 " return function () { return this; };"
288 "})()";
289
290 v8::Isolate* isolate = CcTest::isolate();
291 v8::HandleScope outer(isolate);
292 v8::Local<v8::Value> fun;
293 {
294 v8::Local<v8::Context> env = v8::Context::New(isolate);
295 env->Enter();
296 CompileRun("var x = 42;");
297 fun = CompileRun(script);
298 env->Global()->Set(v8_str("foo"), fun);
299 ExpectObject("foo()", env->Global());
300 env->Exit();
301 }
302
303 {
304 v8::Local<v8::Context> env = v8::Context::New(isolate);
305 env->Enter();
306 v8::Local<v8::Value> fun2 = CompileRun(script);
307 i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun);
308 i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun);
309 i::Handle<i::Object> oifun2 = v8::Utils::OpenHandle(*fun2);
310 i::Handle<i::JSFunction> ifun2 = Handle<JSFunction>::cast(oifun2);
311 ifun2->set_code(ifun->code());
312 env->Global()->Set(v8_str("foo"), fun2);
313 CompileRun("var x = 24;");
314 ExpectObject("foo()", env->Global());
315 env->Exit();
316 }
317 }
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698