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

Unified Diff: test/cctest/compiler/function-tester.h

Issue 484273003: Load closure from activation for building literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Load closure from activation for building literals. 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
Index: test/cctest/compiler/function-tester.h
diff --git a/test/cctest/compiler/function-tester.h b/test/cctest/compiler/function-tester.h
index 67b704db911d30add319c8a670f6ed4f05607d19..1e16d4fa5ec28369d6d966b8b782e448cc6a37cf 100644
--- a/test/cctest/compiler/function-tester.h
+++ b/test/cctest/compiler/function-tester.h
@@ -26,9 +26,11 @@ namespace compiler {
class FunctionTester : public InitializedHandleScope {
public:
- explicit FunctionTester(const char* source)
+ explicit FunctionTester(const char* source, bool context_specialization =
+ FLAG_context_specialization)
: isolate(main_isolate()),
- function((FLAG_allow_natives_syntax = true, NewFunction(source))) {
+ function((FLAG_allow_natives_syntax = true, NewFunction(source))),
+ context_specialization_(context_specialization) {
Compile(function);
}
@@ -51,7 +53,7 @@ class FunctionTester : public InitializedHandleScope {
EnsureDeoptimizationSupport(&info);
- Pipeline pipeline(&info);
+ Pipeline pipeline(&info, context_specialization_);
Handle<Code> code = pipeline.GenerateCode();
CHECK(!code.is_null());
@@ -188,6 +190,27 @@ class FunctionTester : public InitializedHandleScope {
Handle<Object> true_value() { return isolate->factory()->true_value(); }
Handle<Object> false_value() { return isolate->factory()->false_value(); }
+
+ template <typename Lambda>
+ void RunInSeparateContext(const char* script, Lambda body) {
+ v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
+ v8::Context::Scope scope(env);
+ v8::Local<v8::Value> val = CompileRun(script);
+ body(env, val);
+ }
+
+ template <typename Lambda>
+ void CompileFunctionInSeparateContext(const char* script, Lambda body) {
+ RunInSeparateContext(script, [&body](v8::Handle<v8::Context> context,
+ v8::Handle<Value> value) {
+ i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value);
+ i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun);
+ body(context, jsfun);
+ });
+ }
+
+ private:
+ bool context_specialization_;
};
}
}

Powered by Google App Engine
This is Rietveld 408576698