Revert of [V8] Added Script::is_opaque flag for embedders (patchset #5 id:80001 of https://codereview.chromium.org/1140673002/)

Reason for revert:
[Sheriff] Breaks chromium win compilation:
http://build.chromium.org/p/client.v8.fyi/builders/V8-Blink%20Win/builds/96

Original issue's description:
> [V8] Added Script::is_opaque flag for embedders
>
> When the page is controlled by a ServiceWorker, the ServiceWorker can return an opaque (non-CORS cross origin) resource response.
> We need to treat the messages from such script resource as opaque.
>
> Committed: https://crrev.com/7a599c5e1242d3c5ab7515ee149623da90ae69ec
> Cr-Commit-Position: refs/heads/master@{#28445}

TBR=mkwst@chromium.org,jochen@chromium.org,yangguo@chromium.org,horo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#28449}
This commit is contained in:
machenbach 2015-05-18 07:54:54 -07:00 committed by Commit bot
parent 9d17058651
commit 91f38435ea
16 changed files with 139 additions and 172 deletions

View File

@ -972,34 +972,6 @@ class V8_EXPORT Data {
};
/**
* The optional attributes of ScriptOrigin.
*/
class ScriptOriginOptions {
public:
V8_INLINE ScriptOriginOptions(bool is_embedder_debug_script = false,
bool is_shared_cross_origin = false,
bool is_opaque = false)
: flags_((is_embedder_debug_script ? kIsEmbedderDebugScript : 0) |
(is_shared_cross_origin ? kIsSharedCrossOrigin : 0) |
(is_opaque ? kIsOpaque : 0)) {}
V8_INLINE ScriptOriginOptions(int flags)
: flags_(flags &
(kIsEmbedderDebugScript | kIsSharedCrossOrigin | kIsOpaque)) {}
bool IsEmbedderDebugScript() const { return flags_ & kIsEmbedderDebugScript; }
bool IsSharedCrossOrigin() const { return flags_ & kIsSharedCrossOrigin; }
bool IsOpaque() const { return flags_ & kIsOpaque; }
int Flags() const { return flags_; }
private:
enum {
kIsEmbedderDebugScript = 1,
kIsSharedCrossOrigin = 1 << 1,
kIsOpaque = 1 << 2
};
const int flags_;
};
/**
* The origin, within a file, of a script.
*/
@ -1012,23 +984,31 @@ class ScriptOrigin {
Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>(),
Handle<Integer> script_id = Handle<Integer>(),
Handle<Boolean> resource_is_embedder_debug_script = Handle<Boolean>(),
Handle<Value> source_map_url = Handle<Value>(),
Handle<Boolean> resource_is_opaque = Handle<Boolean>());
Handle<Value> source_map_url = Handle<Value>())
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
resource_is_embedder_debug_script_(resource_is_embedder_debug_script),
resource_is_shared_cross_origin_(resource_is_shared_cross_origin),
script_id_(script_id),
source_map_url_(source_map_url) {}
V8_INLINE Handle<Value> ResourceName() const;
V8_INLINE Handle<Integer> ResourceLineOffset() const;
V8_INLINE Handle<Integer> ResourceColumnOffset() const;
/**
* Returns true for embedder's debugger scripts
*/
V8_INLINE Handle<Boolean> ResourceIsEmbedderDebugScript() const;
V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
V8_INLINE Handle<Integer> ScriptID() const;
V8_INLINE Handle<Value> SourceMapUrl() const;
V8_INLINE ScriptOriginOptions Options() const { return options_; }
private:
Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_;
ScriptOriginOptions options_;
Handle<Boolean> resource_is_embedder_debug_script_;
Handle<Boolean> resource_is_shared_cross_origin_;
Handle<Integer> script_id_;
Handle<Value> source_map_url_;
};
@ -1180,7 +1160,8 @@ class V8_EXPORT ScriptCompiler {
Handle<Value> resource_name;
Handle<Integer> resource_line_offset;
Handle<Integer> resource_column_offset;
ScriptOriginOptions resource_options;
Handle<Boolean> resource_is_embedder_debug_script;
Handle<Boolean> resource_is_shared_cross_origin;
Handle<Value> source_map_url;
// Cached data from previous compilation (if a kConsume*Cache flag is
@ -1469,7 +1450,6 @@ class V8_EXPORT Message {
* this Message was generated to V8.
*/
bool IsSharedCrossOrigin() const;
bool IsOpaque() const;
// TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(Isolate* isolate, FILE* out);
@ -7246,24 +7226,6 @@ int FunctionCallbackInfo<T>::Length() const {
return length_;
}
ScriptOrigin::ScriptOrigin(Handle<Value> resource_name,
Handle<Integer> resource_line_offset,
Handle<Integer> resource_column_offset,
Handle<Boolean> resource_is_shared_cross_origin,
Handle<Integer> script_id,
Handle<Boolean> resource_is_embedder_debug_script,
Handle<Value> source_map_url,
Handle<Boolean> resource_is_opaque)
: resource_name_(resource_name),
resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset),
options_(!resource_is_embedder_debug_script.IsEmpty() &&
resource_is_embedder_debug_script->IsTrue(),
!resource_is_shared_cross_origin.IsEmpty() &&
resource_is_shared_cross_origin->IsTrue(),
!resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue()),
script_id_(script_id),
source_map_url_(source_map_url) {}
Handle<Value> ScriptOrigin::ResourceName() const {
return resource_name_;
@ -7280,6 +7242,16 @@ Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
}
Handle<Boolean> ScriptOrigin::ResourceIsEmbedderDebugScript() const {
return resource_is_embedder_debug_script_;
}
Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const {
return resource_is_shared_cross_origin_;
}
Handle<Integer> ScriptOrigin::ScriptID() const {
return script_id_;
}
@ -7294,7 +7266,8 @@ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
resource_name(origin.ResourceName()),
resource_line_offset(origin.ResourceLineOffset()),
resource_column_offset(origin.ResourceColumnOffset()),
resource_options(origin.Options()),
resource_is_embedder_debug_script(origin.ResourceIsEmbedderDebugScript()),
resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()),
source_map_url(origin.SourceMapUrl()),
cached_data(data) {}

View File

@ -677,9 +677,8 @@ void Accessors::ScriptIsEmbedderDebugScriptGetter(
DisallowHeapAllocation no_allocation;
HandleScope scope(isolate);
Object* object = *Utils::OpenHandle(*info.This());
bool is_embedder_debug_script = Script::cast(JSValue::cast(object)->value())
->origin_options()
.IsEmbedderDebugScript();
bool is_embedder_debug_script =
Script::cast(JSValue::cast(object)->value())->is_embedder_debug_script();
Object* res = *isolate->factory()->ToBoolean(is_embedder_debug_script);
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
}

View File

@ -188,16 +188,14 @@ static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate,
i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate);
v8::Isolate* v8_isolate =
reinterpret_cast<v8::Isolate*>(script->GetIsolate());
ScriptOriginOptions options(script->origin_options());
v8::ScriptOrigin origin(
Utils::ToLocal(scriptName),
v8::Integer::New(v8_isolate, script->line_offset()->value()),
v8::Integer::New(v8_isolate, script->column_offset()->value()),
v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()),
v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()),
v8::Integer::New(v8_isolate, script->id()->value()),
v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()),
Utils::ToLocal(source_map_url),
v8::Boolean::New(v8_isolate, options.IsOpaque()));
v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()),
Utils::ToLocal(source_map_url));
return origin;
}
@ -1718,6 +1716,8 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
i::Handle<i::Object> source_map_url;
int line_offset = 0;
int column_offset = 0;
bool is_embedder_debug_script = false;
bool is_shared_cross_origin = false;
if (!source->resource_name.IsEmpty()) {
name_obj = Utils::OpenHandle(*(source->resource_name));
}
@ -1728,13 +1728,21 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal(
column_offset =
static_cast<int>(source->resource_column_offset->Value());
}
if (!source->resource_is_shared_cross_origin.IsEmpty()) {
is_shared_cross_origin =
source->resource_is_shared_cross_origin->IsTrue();
}
if (!source->resource_is_embedder_debug_script.IsEmpty()) {
is_embedder_debug_script =
source->resource_is_embedder_debug_script->IsTrue();
}
if (!source->source_map_url.IsEmpty()) {
source_map_url = Utils::OpenHandle(*(source->source_map_url));
}
result = i::Compiler::CompileScript(
str, name_obj, line_offset, column_offset, source->resource_options,
source_map_url, isolate->native_context(), NULL, &script_data, options,
i::NOT_NATIVES_CODE, is_module);
str, name_obj, line_offset, column_offset, is_embedder_debug_script,
is_shared_cross_origin, source_map_url, isolate->native_context(), NULL,
&script_data, 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
@ -1968,7 +1976,14 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
script->set_column_offset(i::Smi::FromInt(
static_cast<int>(origin.ResourceColumnOffset()->Value())));
}
script->set_origin_options(origin.Options());
if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) {
script->set_is_shared_cross_origin(
origin.ResourceIsSharedCrossOrigin()->IsTrue());
}
if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) {
script->set_is_embedder_debug_script(
origin.ResourceIsEmbedderDebugScript()->IsTrue());
}
if (!origin.SourceMapUrl().IsEmpty()) {
script->set_source_mapping_url(
*Utils::OpenHandle(*(origin.SourceMapUrl())));
@ -2347,18 +2362,7 @@ bool Message::IsSharedCrossOrigin() const {
auto self = Utils::OpenHandle(this);
auto script = i::Handle<i::JSValue>::cast(
i::Handle<i::Object>(self->script(), isolate));
return i::Script::cast(script->value())
->origin_options()
.IsSharedCrossOrigin();
}
bool Message::IsOpaque() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8(isolate);
auto self = Utils::OpenHandle(this);
auto script = i::Handle<i::JSValue>::cast(
i::Handle<i::Object>(self->script(), isolate));
return i::Script::cast(script->value())->origin_options().IsOpaque();
return i::Script::cast(script->value())->is_shared_cross_origin();
}

View File

@ -1493,9 +1493,8 @@ bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name,
Handle<String> script_name =
isolate->factory()->NewStringFromUtf8(name).ToHandleChecked();
Handle<SharedFunctionInfo> function_info = Compiler::CompileScript(
source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
context, NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE,
false);
source, script_name, 0, 0, false, false, Handle<Object>(), context, NULL,
NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false);
DCHECK(context->IsNativeContext());
@ -1538,9 +1537,9 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
Handle<String> script_name =
factory->NewStringFromUtf8(name).ToHandleChecked();
function_info = Compiler::CompileScript(
source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
context, extension, NULL, ScriptCompiler::kNoCompileOptions,
NOT_NATIVES_CODE, false);
source, script_name, 0, 0, false, false, Handle<Object>(), context,
extension, NULL, ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE,
false);
if (function_info.is_null()) return false;
cache->Add(name, function_info);
}

View File

@ -113,7 +113,8 @@ CompilationCacheScript::CompilationCacheScript(Isolate* isolate,
bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
Handle<Object> name, int line_offset,
int column_offset,
ScriptOriginOptions resource_options) {
bool is_embedder_debug_script,
bool is_shared_cross_origin) {
Handle<Script> script =
Handle<Script>(Script::cast(function_info->script()), isolate());
// If the script name isn't set, the boilerplate script should have
@ -126,9 +127,12 @@ bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
if (column_offset != script->column_offset()->value()) return false;
// Check that both names are strings. If not, no match.
if (!name->IsString() || !script->name()->IsString()) return false;
// Are the origin_options same?
if (resource_options.Flags() != script->origin_options().Flags())
// Were both scripts tagged by the embedder as being internal script?
if (is_embedder_debug_script != script->is_embedder_debug_script()) {
return false;
}
// Were both scripts tagged by the embedder as being shared cross-origin?
if (is_shared_cross_origin != script->is_shared_cross_origin()) return false;
// Compare the two name strings for equality.
return String::Equals(Handle<String>::cast(name),
Handle<String>(String::cast(script->name())));
@ -141,8 +145,9 @@ bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
// won't.
Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
Handle<String> source, Handle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<Context> context, LanguageMode language_mode) {
int column_offset, bool is_embedder_debug_script,
bool is_shared_cross_origin, Handle<Context> context,
LanguageMode language_mode) {
Object* result = NULL;
int generation;
@ -158,7 +163,7 @@ Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
// Break when we've found a suitable shared function info that
// matches the origin.
if (HasOrigin(function_info, name, line_offset, column_offset,
resource_options)) {
is_embedder_debug_script, is_shared_cross_origin)) {
result = *function_info;
break;
}
@ -172,8 +177,8 @@ Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
if (result != NULL) {
Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result),
isolate());
DCHECK(
HasOrigin(shared, name, line_offset, column_offset, resource_options));
DCHECK(HasOrigin(shared, name, line_offset, column_offset,
is_embedder_debug_script, is_shared_cross_origin));
// If the script was found in a later generation, we promote it to
// the first generation to let it survive longer in the cache.
if (generation != 0) Put(source, context, language_mode, shared);
@ -287,12 +292,14 @@ void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) {
MaybeHandle<SharedFunctionInfo> CompilationCache::LookupScript(
Handle<String> source, Handle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<Context> context, LanguageMode language_mode) {
int column_offset, bool is_embedder_debug_script,
bool is_shared_cross_origin, Handle<Context> context,
LanguageMode language_mode) {
if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
return script_.Lookup(source, name, line_offset, column_offset,
resource_options, context, language_mode);
is_embedder_debug_script, is_shared_cross_origin,
context, language_mode);
}

View File

@ -74,7 +74,8 @@ class CompilationCacheScript : public CompilationSubCache {
Handle<SharedFunctionInfo> Lookup(Handle<String> source, Handle<Object> name,
int line_offset, int column_offset,
ScriptOriginOptions resource_options,
bool is_embedder_debug_script,
bool is_shared_cross_origin,
Handle<Context> context,
LanguageMode language_mode);
void Put(Handle<String> source,
@ -85,7 +86,7 @@ class CompilationCacheScript : public CompilationSubCache {
private:
bool HasOrigin(Handle<SharedFunctionInfo> function_info, Handle<Object> name,
int line_offset, int column_offset,
ScriptOriginOptions resource_options);
bool is_embedder_debug_script, bool is_shared_cross_origin);
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
};
@ -148,8 +149,9 @@ class CompilationCache {
// script for the given source string with the right origin.
MaybeHandle<SharedFunctionInfo> LookupScript(
Handle<String> source, Handle<Object> name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<Context> context, LanguageMode language_mode);
int column_offset, bool is_embedder_debug_script,
bool is_shared_cross_origin, Handle<Context> context,
LanguageMode language_mode);
// Finds the shared function info for a source string for eval in a
// given context. Returns an empty handle if the cache doesn't

View File

@ -1185,9 +1185,9 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
Handle<SharedFunctionInfo> Compiler::CompileScript(
Handle<String> source, Handle<Object> script_name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
Handle<Object> source_map_url, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
int column_offset, bool is_embedder_debug_script,
bool is_shared_cross_origin, Handle<Object> source_map_url,
Handle<Context> context, v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options, NativesFlag natives,
bool is_module) {
Isolate* isolate = source->GetIsolate();
@ -1222,8 +1222,9 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
if (extension == NULL) {
// First check per-isolate compilation cache.
maybe_result = compilation_cache->LookupScript(
source, script_name, line_offset, column_offset, resource_options,
context, language_mode);
source, script_name, line_offset, column_offset,
is_embedder_debug_script, is_shared_cross_origin, context,
language_mode);
if (maybe_result.is_null() && FLAG_serialize_toplevel &&
compile_options == ScriptCompiler::kConsumeCodeCache &&
!isolate->debug()->is_loaded()) {
@ -1260,7 +1261,8 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
script->set_line_offset(Smi::FromInt(line_offset));
script->set_column_offset(Smi::FromInt(column_offset));
}
script->set_origin_options(resource_options);
script->set_is_shared_cross_origin(is_shared_cross_origin);
script->set_is_embedder_debug_script(is_embedder_debug_script);
if (!source_map_url.is_null()) {
script->set_source_mapping_url(*source_map_url);
}

View File

@ -624,7 +624,7 @@ class Compiler : public AllStatic {
// Compile a String source within a context.
static Handle<SharedFunctionInfo> CompileScript(
Handle<String> source, Handle<Object> script_name, int line_offset,
int column_offset, ScriptOriginOptions resource_options,
int column_offset, bool is_debugger_script, bool is_shared_cross_origin,
Handle<Object> source_map_url, Handle<Context> context,
v8::Extension* extension, ScriptData** cached_data,
ScriptCompiler::CompileOptions compile_options,

View File

@ -645,9 +645,8 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
// Compile the script.
Handle<SharedFunctionInfo> function_info;
function_info = Compiler::CompileScript(
source_code, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(),
context, NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE,
false);
source_code, script_name, 0, 0, false, false, Handle<Object>(), context,
NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false);
// Silently ignore stack overflows during compilation.
if (function_info.is_null()) {

View File

@ -5551,6 +5551,9 @@ ACCESSORS(Script, eval_from_shared, Object, kEvalFromSharedOffset)
ACCESSORS_TO_SMI(Script, eval_from_instructions_offset,
kEvalFrominstructionsOffsetOffset)
ACCESSORS_TO_SMI(Script, flags, kFlagsOffset)
BOOL_ACCESSORS(Script, flags, is_embedder_debug_script,
kIsEmbedderDebugScriptBit)
BOOL_ACCESSORS(Script, flags, is_shared_cross_origin, kIsSharedCrossOriginBit)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
@ -5570,15 +5573,6 @@ void Script::set_compilation_state(CompilationState state) {
set_flags(BooleanBit::set(flags(), kCompilationStateBit,
state == COMPILATION_STATE_COMPILED));
}
ScriptOriginOptions Script::origin_options() {
return ScriptOriginOptions((flags()->value() & kOriginOptionsMask) >>
kOriginOptionsShift);
}
void Script::set_origin_options(ScriptOriginOptions origin_options) {
DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
set_flags(Smi::FromInt((flags()->value() & ~kOriginOptionsMask) |
(origin_options.Flags() << kOriginOptionsShift)));
}
ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoIndex)

View File

@ -6738,11 +6738,17 @@ class Script: public Struct {
inline CompilationState compilation_state();
inline void set_compilation_state(CompilationState state);
// [origin_options]: optional attributes set by the embedder via ScriptOrigin,
// and used by the embedder to make decisions about the script. V8 just passes
// this through. Encoded in the 'flags' field.
inline v8::ScriptOriginOptions origin_options();
inline void set_origin_options(ScriptOriginOptions origin_options);
// [is_embedder_debug_script]: An opaque boolean set by the embedder via
// ScriptOrigin, and used by the embedder to make decisions about the
// script's origin. V8 just passes this through. Encoded in
// the 'flags' field.
DECL_BOOLEAN_ACCESSORS(is_embedder_debug_script)
// [is_shared_cross_origin]: An opaque boolean set by the embedder via
// ScriptOrigin, and used by the embedder to make decisions about the
// script's level of privilege. V8 just passes this through. Encoded in
// the 'flags' field.
DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin)
DECLARE_CAST(Script)
@ -6794,10 +6800,8 @@ class Script: public Struct {
// Bit positions in the flags field.
static const int kCompilationTypeBit = 0;
static const int kCompilationStateBit = 1;
static const int kOriginOptionsShift = 2;
static const int kOriginOptionsSize = 3;
static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
<< kOriginOptionsShift;
static const int kIsEmbedderDebugScriptBit = 2;
static const int kIsSharedCrossOriginBit = 3;
DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
};

View File

@ -34,8 +34,8 @@ static Handle<JSFunction> Compile(const char* source) {
->NewStringFromUtf8(CStrVector(source))
.ToHandleChecked();
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(),
Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());

View File

@ -4039,9 +4039,8 @@ TEST(MessageHandler2) {
static void check_message_3(v8::Handle<v8::Message> message,
v8::Handle<Value> data) {
CHECK(message->IsSharedCrossOrigin());
CHECK(message->GetScriptOrigin().Options().IsSharedCrossOrigin());
CHECK(message->GetScriptOrigin().Options().IsEmbedderDebugScript());
CHECK(message->GetScriptOrigin().Options().IsOpaque());
CHECK(message->GetScriptOrigin().ResourceIsSharedCrossOrigin()->Value());
CHECK(message->GetScriptOrigin().ResourceIsEmbedderDebugScript()->Value());
CHECK_EQ(6.75, message->GetScriptOrigin().ResourceName()->NumberValue());
CHECK_EQ(7.40, message->GetScriptOrigin().SourceMapUrl()->NumberValue());
message_received = true;
@ -4058,7 +4057,7 @@ TEST(MessageHandler3) {
v8::ScriptOrigin origin = v8::ScriptOrigin(
v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::True(isolate), Handle<v8::Integer>(),
v8::True(isolate), v8_str("7.40"), v8::True(isolate));
v8::True(isolate), v8_str("7.40"));
v8::Handle<v8::Script> script =
Script::Compile(v8_str("throw 'error'"), &origin);
script->Run();
@ -4118,11 +4117,11 @@ TEST(MessageHandler5) {
CHECK(!message_received);
v8::V8::AddMessageListener(check_message_5a);
LocalContext context;
v8::ScriptOrigin origin1 =
v8::ScriptOrigin origin =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::True(isolate));
v8::Handle<v8::Script> script =
Script::Compile(v8_str("throw 'error'"), &origin1);
Script::Compile(v8_str("throw 'error'"), &origin);
script->Run();
CHECK(message_received);
// clear out the message listener
@ -4130,10 +4129,9 @@ TEST(MessageHandler5) {
message_received = false;
v8::V8::AddMessageListener(check_message_5b);
v8::ScriptOrigin origin2 =
v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::False(isolate));
script = Script::Compile(v8_str("throw 'error'"), &origin2);
origin = v8::ScriptOrigin(v8_str("6.75"), v8::Integer::New(isolate, 1),
v8::Integer::New(isolate, 2), v8::False(isolate));
script = Script::Compile(v8_str("throw 'error'"), &origin);
script->Run();
CHECK(message_received);
// clear out the message listener
@ -15613,8 +15611,7 @@ THREADED_TEST(ScriptOrigin) {
v8::Integer::New(env->GetIsolate(), 1),
v8::Integer::New(env->GetIsolate(), 1), v8::True(env->GetIsolate()),
v8::Handle<v8::Integer>(), v8::True(env->GetIsolate()),
v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"),
v8::True(env->GetIsolate()));
v8::String::NewFromUtf8(env->GetIsolate(), "http://sourceMapUrl"));
v8::Handle<v8::String> script = v8::String::NewFromUtf8(
env->GetIsolate(), "function f() {}\n\nfunction g() {}");
v8::Script::Compile(script, &origin)->Run();
@ -15627,9 +15624,8 @@ THREADED_TEST(ScriptOrigin) {
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_f.ResourceName())));
CHECK_EQ(1, script_origin_f.ResourceLineOffset()->Int32Value());
CHECK(script_origin_f.Options().IsSharedCrossOrigin());
CHECK(script_origin_f.Options().IsEmbedderDebugScript());
CHECK(script_origin_f.Options().IsOpaque());
CHECK(script_origin_f.ResourceIsSharedCrossOrigin()->Value());
CHECK(script_origin_f.ResourceIsEmbedderDebugScript()->Value());
printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined());
CHECK_EQ(0, strcmp("http://sourceMapUrl",
@ -15639,9 +15635,8 @@ THREADED_TEST(ScriptOrigin) {
CHECK_EQ(0, strcmp("test",
*v8::String::Utf8Value(script_origin_g.ResourceName())));
CHECK_EQ(1, script_origin_g.ResourceLineOffset()->Int32Value());
CHECK(script_origin_g.Options().IsSharedCrossOrigin());
CHECK(script_origin_g.Options().IsEmbedderDebugScript());
CHECK(script_origin_g.Options().IsOpaque());
CHECK(script_origin_g.ResourceIsSharedCrossOrigin()->Value());
CHECK(script_origin_g.ResourceIsEmbedderDebugScript()->Value());
CHECK_EQ(0, strcmp("http://sourceMapUrl",
*v8::String::Utf8Value(script_origin_g.SourceMapUrl())));
}

View File

@ -60,8 +60,8 @@ static Handle<JSFunction> Compile(const char* source) {
Handle<String> source_code = isolate->factory()->NewStringFromUtf8(
CStrVector(source)).ToHandleChecked();
Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript(
source_code, Handle<String>(), 0, 0, v8::ScriptOriginOptions(),
Handle<Object>(), Handle<Context>(isolate->native_context()), NULL, NULL,
source_code, Handle<String>(), 0, 0, false, false, Handle<Object>(),
Handle<Context>(isolate->native_context()), NULL, NULL,
v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, false);
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_function, isolate->native_context());

View File

@ -1377,8 +1377,7 @@ TEST(CompilationCacheCachingBehavior) {
// On first compilation, only a hash is inserted in the code cache. We can't
// find that value.
MaybeHandle<SharedFunctionInfo> info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
source, Handle<Object>(), 0, 0, false, true, native_context,
language_mode);
CHECK(info.is_null());
@ -1389,20 +1388,16 @@ TEST(CompilationCacheCachingBehavior) {
// On second compilation, the hash is replaced by a real cache entry mapping
// the source to the shared function info containing the code.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
true, native_context, language_mode);
CHECK(!info.is_null());
heap->CollectAllGarbage();
// On second compilation, the hash is replaced by a real cache entry mapping
// the source to the shared function info containing the code.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
true, native_context, language_mode);
CHECK(!info.is_null());
while (!info.ToHandleChecked()->code()->IsOld()) {
@ -1411,10 +1406,8 @@ TEST(CompilationCacheCachingBehavior) {
heap->CollectAllGarbage();
// Ensure code aging cleared the entry from the cache.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
true, native_context, language_mode);
CHECK(info.is_null());
{
@ -1424,10 +1417,8 @@ TEST(CompilationCacheCachingBehavior) {
// On first compilation, only a hash is inserted in the code cache. We can't
// find that value.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
true, native_context, language_mode);
CHECK(info.is_null());
for (int i = 0; i < CompilationCacheTable::kHashGenerations; i++) {
@ -1441,10 +1432,8 @@ TEST(CompilationCacheCachingBehavior) {
// If we aged the cache before caching the script, ensure that we didn't cache
// on next compilation.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
info = compilation_cache->LookupScript(source, Handle<Object>(), 0, 0, false,
true, native_context, language_mode);
CHECK(info.is_null());
}

View File

@ -808,7 +808,7 @@ 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, v8::ScriptOriginOptions(), Handle<Object>(),
source, name, 0, 0, false, false, Handle<Object>(),
Handle<Context>(isolate->native_context()), NULL, cached_data, options,
NOT_NATIVES_CODE, false);
}
@ -887,7 +887,7 @@ TEST(CodeCachePromotedToCompilationCache) {
isolate, src, src, &cache, v8::ScriptCompiler::kConsumeCodeCache);
CHECK(isolate->compilation_cache()
->LookupScript(src, src, 0, 0, v8::ScriptOriginOptions(),
->LookupScript(src, src, 0, 0, false, false,
isolate->native_context(), SLOPPY)
.ToHandleChecked()
.is_identical_to(copy));