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

Unified Diff: test/cctest/cctest.h

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/x64/stub-cache-x64.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/cctest.h
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h
index a4991a5a19711f8d71c2a38a151b9c953d815aac..93195102d4a99d2b5fa7c40dbb8ee90e7098f0c4 100644
--- a/test/cctest/cctest.h
+++ b/test/cctest/cctest.h
@@ -308,39 +308,89 @@ static inline v8::Local<v8::Script> v8_compile(const char* x) {
}
-// Helper function that compiles and runs the source.
+static inline v8::Local<v8::Script> v8_compile(v8::Local<v8::String> x) {
+ return v8::Script::Compile(x);
+}
+
+
+static inline v8::Local<v8::Script> CompileWithOrigin(
+ v8::Local<v8::String> source, v8::Local<v8::String> origin_url) {
+ v8::ScriptOrigin origin(origin_url);
+ return v8::ScriptCompiler::Compile(
+ v8::Isolate::GetCurrent(), v8::ScriptCompiler::Source(source, origin));
+}
+
+
+static inline v8::Local<v8::Script> CompileWithOrigin(
+ v8::Local<v8::String> source, const char* origin_url) {
+ return CompileWithOrigin(source, v8_str(origin_url));
+}
+
+
+static inline v8::Local<v8::Script> CompileWithOrigin(const char* source,
+ const char* origin_url) {
+ return CompileWithOrigin(v8_str(source), v8_str(origin_url));
+}
+
+
+// Helper functions that compile and run the source.
static inline v8::Local<v8::Value> CompileRun(const char* source) {
- return v8::Script::Compile(
- v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source))->Run();
+ return v8::Script::Compile(v8_str(source))->Run();
+}
+
+
+static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
+ return v8::Script::Compile(source)->Run();
}
static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) {
- v8::Local<v8::String> script_source =
- v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), source);
- v8::ScriptData* preparse = v8::ScriptData::PreCompile(script_source);
- v8::Local<v8::Script> script =
- v8::Script::Compile(script_source, NULL, preparse);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::Local<v8::String> source_string =
+ v8::String::NewFromUtf8(isolate, source);
+ v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string);
+ v8::ScriptCompiler::Source script_source(
+ source_string, v8::ScriptCompiler::CachedData(
+ reinterpret_cast<const uint8_t*>(preparse->Data()),
+ preparse->Length()));
+ v8::Local<v8::Script> script = v8::ScriptCompiler::Compile(
+ isolate, v8::ScriptCompiler::Source(script_source));
v8::Local<v8::Value> result = script->Run();
delete preparse;
return result;
}
-// Helper function that compiles and runs the source with given origin.
+// Helper functions that compile and run the source with given origin.
static inline v8::Local<v8::Value> CompileRunWithOrigin(const char* source,
const char* origin_url,
int line_number,
int column_number) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::ScriptOrigin origin(v8::String::NewFromUtf8(isolate, origin_url),
+ v8::ScriptOrigin origin(v8_str(origin_url),
v8::Integer::New(isolate, line_number),
v8::Integer::New(isolate, column_number));
- return v8::Script::Compile(v8::String::NewFromUtf8(isolate, source), &origin)
+ return v8::ScriptCompiler::Compile(
+ isolate, v8::ScriptCompiler::Source(v8_str(source), origin))
->Run();
}
+static inline v8::Local<v8::Value> CompileRunWithOrigin(
+ v8::Local<v8::String> source, const char* origin_url) {
+ v8::ScriptOrigin origin(v8_str(origin_url));
+ return v8::ScriptCompiler::Compile(
+ v8::Isolate::GetCurrent(),
+ v8::ScriptCompiler::Source(source, origin))->Run();
+}
+
+
+static inline v8::Local<v8::Value> CompileRunWithOrigin(
+ const char* source, const char* origin_url) {
+ return CompileRunWithOrigin(v8_str(source), origin_url);
+}
+
+
// Pick a slightly different port to allow tests to be run in parallel.
static inline int FlagDependentPortOffset() {
return ::v8::internal::FLAG_crankshaft == false ? 100 :
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698