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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-jscalls.cc
diff --git a/test/cctest/compiler/test-run-jscalls.cc b/test/cctest/compiler/test-run-jscalls.cc
index 2ad7e50467edcf87a4a773675d326772207af5a4..179e11835ad9faa0cd68593fdd851bd1f912f57f 100644
--- a/test/cctest/compiler/test-run-jscalls.cc
+++ b/test/cctest/compiler/test-run-jscalls.cc
@@ -233,3 +233,85 @@ TEST(ReceiverPatching) {
Handle<JSObject> g(T.function->context()->global_object()->global_proxy());
T.CheckCall(g, T.undefined());
}
+
+
+THREADED_TEST(ContextLoadedFromActivation) {
+ i::FLAG_turbo_filter = "*";
+ i::FLAG_always_opt = true;
+ i::FLAG_context_specialization = false;
+
+ const char* script =
+ "var x = 42;"
+ "(function() {"
+ " return function () { return x };"
+ "})()";
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope outer(isolate);
+ v8::Local<v8::Value> fun;
+ {
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
+ CompileRun("var x = 42;");
+ fun = CompileRun(script);
+ env->Global()->Set(v8_str("foo"), fun);
+ ExpectInt32("foo();", 42);
+ env->Exit();
+ }
+
+ {
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
+ v8::Local<v8::Value> fun2 = CompileRun(script);
+ i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun);
+ i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun);
+ i::Handle<i::Object> oifun2 = v8::Utils::OpenHandle(*fun2);
+ i::Handle<i::JSFunction> ifun2 = Handle<JSFunction>::cast(oifun2);
+ ifun2->set_code(ifun->code());
+ env->Global()->Set(v8_str("foo"), fun2);
+ CompileRun("var x = 24;");
+ ExpectInt32("foo();", 24);
+ env->Exit();
+ }
+}
+
+
+THREADED_TEST(BuiltinLoadedFromActivation) {
+ i::FLAG_turbo_filter = "*";
+ i::FLAG_always_opt = true;
+ i::FLAG_context_specialization = false;
+
+ const char* script =
+ "var x = 42;"
+ "(function() {"
+ " return function () { return this; };"
+ "})()";
+
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope outer(isolate);
+ v8::Local<v8::Value> fun;
+ {
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
+ CompileRun("var x = 42;");
+ fun = CompileRun(script);
+ env->Global()->Set(v8_str("foo"), fun);
+ ExpectObject("foo()", env->Global());
+ env->Exit();
+ }
+
+ {
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
+ env->Enter();
+ v8::Local<v8::Value> fun2 = CompileRun(script);
+ i::Handle<i::Object> oifun = v8::Utils::OpenHandle(*fun);
+ i::Handle<i::JSFunction> ifun = Handle<JSFunction>::cast(oifun);
+ i::Handle<i::Object> oifun2 = v8::Utils::OpenHandle(*fun2);
+ i::Handle<i::JSFunction> ifun2 = Handle<JSFunction>::cast(oifun2);
+ ifun2->set_code(ifun->code());
+ env->Global()->Set(v8_str("foo"), fun2);
+ CompileRun("var x = 24;");
+ ExpectObject("foo()", env->Global());
+ env->Exit();
+ }
+}
« 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