Commit 70079dab authored by adamk's avatar adamk Committed by Commit bot

Add basic compilation support for modules

This adds an "experimental" API hook (v8::ScriptCompiler::CompileModule)
allowing compilation of modules. The code gen is incredibly basic: the
module body is represented by a Block in the AST. But this at least gets
more of the pipeline working, and opens the door to writing mjsunit tests
(once d8 is modified to support module compilation).

BUG=v8:1569
LOG=n

Review URL: https://codereview.chromium.org/902093002

Cr-Commit-Position: refs/heads/master@{#26496}
parent fb73392b
......@@ -1308,6 +1308,24 @@ class V8_EXPORT ScriptCompiler {
* compared when it is being used.
*/
static uint32_t CachedDataVersionTag();
/**
* Compile an ES6 module.
*
* This is an experimental feature.
*
* TODO(adamk): Script is likely the wrong return value for this;
* should return some new Module type.
*/
static Local<Script> CompileModule(
Isolate* isolate, Source* source,
CompileOptions options = kNoCompileOptions);
private:
static Local<UnboundScript> CompileUnboundInternal(Isolate* isolate,
Source* source,
CompileOptions options,
bool is_module);
};
......
......@@ -1524,10 +1524,9 @@ Local<UnboundScript> Script::GetUnboundScript() {
}
Local<UnboundScript> ScriptCompiler::CompileUnbound(
Isolate* v8_isolate,
Source* source,
CompileOptions options) {
Local<UnboundScript> ScriptCompiler::CompileUnboundInternal(
Isolate* v8_isolate, Source* source, CompileOptions options,
bool is_module) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
return Local<UnboundScript>());
......@@ -1588,7 +1587,7 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript(
str, name_obj, line_offset, column_offset, is_embedder_debug_script,
is_shared_cross_origin, isolate->native_context(), NULL, &script_data,
options, i::NOT_NATIVES_CODE);
options, i::NOT_NATIVES_CODE, is_module);
has_pending_exception = result.is_null();
if (has_pending_exception && script_data != NULL) {
// This case won't happen during normal operation; we have compiled
......@@ -1617,13 +1616,20 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
}
Local<UnboundScript> ScriptCompiler::CompileUnbound(Isolate* v8_isolate,
Source* source,
CompileOptions options) {
return CompileUnboundInternal(v8_isolate, source, options, false);
}
Local<Script> ScriptCompiler::Compile(
Isolate* v8_isolate,
Source* source,
CompileOptions options) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ON_BAILOUT(isolate, "v8::ScriptCompiler::Compile()", return Local<Script>());
LOG_API(isolate, "ScriptCompiler::CompiletBound()");
LOG_API(isolate, "ScriptCompiler::CompileBound()");
ENTER_V8(isolate);
Local<UnboundScript> generic = CompileUnbound(v8_isolate, source, options);
if (generic.IsEmpty()) return Local<Script>();
......@@ -1631,6 +1637,21 @@ Local<Script> ScriptCompiler::Compile(
}
Local<Script> ScriptCompiler::CompileModule(Isolate* v8_isolate, Source* source,
CompileOptions options) {
CHECK(i::FLAG_harmony_modules);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileModule()",
return Local<Script>());
LOG_API(isolate, "ScriptCompiler::CompileModule()");
ENTER_V8(isolate);
Local<UnboundScript> generic =
CompileUnboundInternal(v8_isolate, source, options, true);
if (generic.IsEmpty()) return Local<Script>();
return generic->BindToCurrentContext();
}
ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript(
Isolate* v8_isolate, StreamedSource* source, CompileOptions options) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
......
......@@ -1454,7 +1454,7 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
function_info = Compiler::CompileScript(
source, script_name, 0, 0, false, false, top_context, extension, NULL,
ScriptCompiler::kNoCompileOptions,
use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE, false);
if (function_info.is_null()) return false;
if (cache != NULL) cache->Add(name, function_info);
}
......
......@@ -1135,7 +1135,7 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
isolate->debug()->OnBeforeCompile(script);
DCHECK(info->is_eval() || info->is_global());
DCHECK(info->is_eval() || info->is_global() || info->is_module());
info->MarkAsToplevel();
......@@ -1280,7 +1280,8 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
int column_offset, bool is_embedder_debug_script,
bool is_shared_cross_origin, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options, NativesFlag natives) {
ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
bool is_module) {
Isolate* isolate = source->GetIsolate();
if (compile_options == ScriptCompiler::kNoCompileOptions) {
cached_data = NULL;
......@@ -1345,7 +1346,11 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
// Compile the function and add it to the cache.
CompilationInfoWithZone info(script);
info.MarkAsGlobal();
if (FLAG_harmony_modules && is_module) {
info.MarkAsModule();
} else {
info.MarkAsGlobal();
}
info.SetCachedData(cached_data, compile_options);
info.SetExtension(extension);
info.SetContext(context);
......
......@@ -728,7 +728,7 @@ class Compiler : public AllStatic {
int column_offset, bool is_debugger_script, bool is_shared_cross_origin,
Handle<Context> context, v8::Extension* extension,
ScriptData** cached_data, ScriptCompiler::CompileOptions compile_options,
NativesFlag is_natives_code);
NativesFlag is_natives_code, bool is_module);
static Handle<SharedFunctionInfo> CompileStreamedScript(CompilationInfo* info,
int source_length);
......
......@@ -745,7 +745,7 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
Handle<SharedFunctionInfo> function_info;
function_info = Compiler::CompileScript(
source_code, script_name, 0, 0, false, false, context, NULL, NULL,
ScriptCompiler::kNoCompileOptions, NATIVES_CODE);
ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false);
// Silently ignore stack overflows during compilation.
if (function_info.is_null()) {
......
......@@ -725,9 +725,14 @@ void FullCodeGenerator::VisitDeclarations(
AstVisitor::VisitDeclarations(declarations);
if (scope_->num_modules() != 0) {
// TODO(ES6): This step, which creates module instance objects,
// can probably be delayed until an "import *" declaration
// reifies a module instance. Until imports are implemented,
// we skip it altogether.
//
// Initialize modules from descriptor array.
DCHECK(module_index_ == modules_->length());
DeclareModules(modules_);
// DCHECK(module_index_ == modules_->length());
// DeclareModules(modules_);
modules_ = saved_modules;
module_index_ = saved_module_index;
}
......
......@@ -955,11 +955,9 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope,
int beg_pos = scanner()->location().beg_pos;
if (info->is_module()) {
DCHECK(allow_harmony_modules());
Module* module = ParseModule(&ok);
Statement* stmt = ParseModule(&ok);
if (ok) {
// TODO(adamk): Do something with returned Module
CHECK(module);
body->Add(factory()->NewEmptyStatement(RelocInfo::kNoPosition), zone());
body->Add(stmt, zone());
}
} else {
ParseStatementList(body, Token::EOS, info->is_eval(), eval_scope, &ok);
......@@ -1255,7 +1253,7 @@ Statement* Parser::ParseModuleItem(bool* ok) {
}
Module* Parser::ParseModule(bool* ok) {
Statement* Parser::ParseModule(bool* ok) {
// (Ecma 262 6th Edition, 15.2):
// Module :
// ModuleBody?
......@@ -1263,21 +1261,14 @@ Module* Parser::ParseModule(bool* ok) {
// ModuleBody :
// ModuleItem*
int pos = peek_position();
// Construct block expecting 16 statements.
Block* body = factory()->NewBlock(NULL, 16, false, RelocInfo::kNoPosition);
#ifdef DEBUG
if (FLAG_print_interface_details) PrintF("# Literal ");
#endif
Scope* scope = NewScope(scope_, MODULE_SCOPE);
scope->set_start_position(scanner()->location().beg_pos);
scope->SetLanguageMode(
static_cast<LanguageMode>(scope->language_mode() | STRICT_BIT));
{
BlockState block_state(&scope_, scope);
Target target(&this->target_stack_, body);
while (peek() != Token::EOS) {
Statement* stat = ParseModuleItem(CHECK_OK);
......@@ -1305,36 +1296,17 @@ Module* Parser::ParseModule(bool* ok) {
DCHECK(*ok);
interface->Freeze(ok);
DCHECK(*ok);
return factory()->NewModuleLiteral(body, interface, pos);
return body;
}
Module* Parser::ParseModuleSpecifier(bool* ok) {
// Module:
// String
Literal* Parser::ParseModuleSpecifier(bool* ok) {
// ModuleSpecifier :
// StringLiteral
int pos = peek_position();
Expect(Token::STRING, CHECK_OK);
const AstRawString* symbol = GetSymbol(scanner());
// TODO(ES6): Request JS resource from environment...
#ifdef DEBUG
if (FLAG_print_interface_details) PrintF("# Url ");
#endif
// Create an empty literal as long as the feature isn't finished.
USE(symbol);
Scope* scope = NewScope(scope_, MODULE_SCOPE);
Block* body = factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition);
body->set_scope(scope);
Interface* interface = scope->interface();
Module* result = factory()->NewModuleLiteral(body, interface, pos);
interface->Freeze(ok);
DCHECK(*ok);
interface->Unify(scope->interface(), zone(), ok);
DCHECK(*ok);
return result;
return factory()->NewStringLiteral(GetSymbol(scanner()), pos);
}
......@@ -1487,7 +1459,7 @@ Statement* Parser::ParseImportDeclaration(bool* ok) {
}
ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
Module* module = ParseModuleSpecifier(CHECK_OK);
Literal* module = ParseModuleSpecifier(CHECK_OK);
USE(module);
ExpectSemicolon(CHECK_OK);
......@@ -1563,7 +1535,7 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
case Token::MUL: {
Consume(Token::MUL);
ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
Module* module = ParseModuleSpecifier(CHECK_OK);
Literal* module = ParseModuleSpecifier(CHECK_OK);
ExpectSemicolon(CHECK_OK);
// TODO(ES6): Do something with the return value
// of ParseModuleSpecifier.
......@@ -1588,7 +1560,7 @@ Statement* Parser::ParseExportDeclaration(bool* ok) {
Scanner::Location reserved_loc = Scanner::Location::invalid();
ParseExportClause(&names, &reserved_loc, CHECK_OK);
if (CheckContextualKeyword(CStrVector("from"))) {
Module* module = ParseModuleSpecifier(CHECK_OK);
Literal* module = ParseModuleSpecifier(CHECK_OK);
// TODO(ES6): Do something with the return value
// of ParseModuleSpecifier.
USE(module);
......
......@@ -741,12 +741,12 @@ class Parser : public ParserBase<ParserTraits> {
// which is set to false if parsing failed; it is unchanged otherwise.
// By making the 'exception handling' explicit, we are forced to check
// for failure at the call sites.
void* ParseStatementList(ZoneList<Statement*>* processor, int end_token,
void* ParseStatementList(ZoneList<Statement*>* body, int end_token,
bool is_eval, Scope** ad_hoc_eval_scope, bool* ok);
Statement* ParseStatementListItem(bool* ok);
Module* ParseModule(bool* ok);
Statement* ParseModule(bool* ok);
Statement* ParseModuleItem(bool* ok);
Module* ParseModuleSpecifier(bool* ok);
Literal* ParseModuleSpecifier(bool* ok);
Statement* ParseImportDeclaration(bool* ok);
Statement* ParseExportDeclaration(bool* ok);
Statement* ParseExportDefault(bool* ok);
......
......@@ -138,6 +138,7 @@
'test-microtask-delivery.cc',
'test-mark-compact.cc',
'test-mementos.cc',
'test-modules.cc',
'test-object-observe.cc',
'test-ordered-hash-table.cc',
'test-parsing.cc',
......
......@@ -389,6 +389,14 @@ static inline v8::Local<v8::Value> CompileRun(const char* source) {
}
// Compiles source as an ES6 module.
static inline v8::Local<v8::Value> CompileRunModule(const char* source) {
v8::ScriptCompiler::Source script_source(v8_str(source));
return v8::ScriptCompiler::CompileModule(v8::Isolate::GetCurrent(),
&script_source)->Run();
}
static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) {
return v8::Script::Compile(source)->Run();
}
......
......@@ -34,7 +34,7 @@ static Handle<JSFunction> Compile(const char* source) {
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
source_code, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());
}
......
......@@ -62,7 +62,7 @@ static Handle<JSFunction> Compile(const char* source) {
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
source_code, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE);
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());
}
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "test/cctest/cctest.h"
TEST(ModuleCompilation) {
v8::internal::FLAG_harmony_modules = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
LocalContext context;
CompileRun(
"var data = [];"
"function store(thing) {"
" data.push(thing);"
"}");
CompileRunModule(
"export let a = 42;"
"store(a)");
CHECK_EQ(1, CompileRun("data.length")->Int32Value());
CHECK_EQ(42, CompileRun("data[0]")->Int32Value());
}
......@@ -732,6 +732,16 @@ int CountBuiltins() {
}
static Handle<SharedFunctionInfo> CompileScript(
Isolate* isolate, Handle<String> source, Handle<String> name,
ScriptData** cached_data, v8::ScriptCompiler::CompileOptions options) {
return Compiler::CompileScript(source, name, 0, 0, false, false,
Handle<Context>(isolate->native_context()),
NULL, cached_data, options, NOT_NATIVES_CODE,
false);
}
TEST(SerializeToplevelOnePlusOne) {
FLAG_serialize_toplevel = true;
LocalContext context;
......@@ -753,20 +763,17 @@ TEST(SerializeToplevelOnePlusOne) {
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
orig_source, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, orig_source, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
int builtins_count = CountBuiltins();
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
copy_source, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, copy_source, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -808,10 +815,9 @@ TEST(SerializeToplevelInternalizedString) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
orig_source, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, orig_source, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<JSFunction> orig_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
orig, isolate->native_context());
......@@ -824,10 +830,8 @@ TEST(SerializeToplevelInternalizedString) {
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
copy_source, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, copy_source, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
CHECK(Script::cast(copy->script())->source() == *copy_source);
......@@ -867,20 +871,17 @@ TEST(SerializeToplevelLargeCodeObject) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
CHECK(isolate->heap()->InSpace(orig->code(), LO_SPACE));
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -923,18 +924,15 @@ TEST(SerializeToplevelLargeStrings) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -996,18 +994,15 @@ TEST(SerializeToplevelThreeBigStrings) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -1104,18 +1099,15 @@ TEST(SerializeToplevelExternalString) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_string, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_string, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_string, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_string, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -1166,18 +1158,15 @@ TEST(SerializeToplevelLargeExternalString) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_str, Handle<String>(), 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_str, Handle<String>(), &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......@@ -1220,18 +1209,15 @@ TEST(SerializeToplevelExternalScriptName) {
Handle<JSObject> global(isolate->context()->global_object());
ScriptData* cache = NULL;
Handle<SharedFunctionInfo> orig = Compiler::CompileScript(
source_string, name, 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE);
Handle<SharedFunctionInfo> orig =
CompileScript(isolate, source_string, name, &cache,
v8::ScriptCompiler::kProduceCodeCache);
Handle<SharedFunctionInfo> copy;
{
DisallowCompilation no_compile_expected(isolate);
copy = Compiler::CompileScript(
source_string, name, 0, 0, false, false,
Handle<Context>(isolate->native_context()), NULL, &cache,
v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE);
copy = CompileScript(isolate, source_string, name, &cache,
v8::ScriptCompiler::kConsumeCodeCache);
}
CHECK_NE(*orig, *copy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment