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

Side by Side Diff: src/api.cc

Issue 1140673002: [V8] Added Script::is_opaque flag for embedders (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Introduces ScriptOriginOptions Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate); 188 i::Handle<i::Object> source_map_url(script->source_mapping_url(), isolate);
189 v8::Isolate* v8_isolate = 189 v8::Isolate* v8_isolate =
190 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); 190 reinterpret_cast<v8::Isolate*>(script->GetIsolate());
191 v8::ScriptOrigin origin( 191 v8::ScriptOrigin origin(
192 Utils::ToLocal(scriptName), 192 Utils::ToLocal(scriptName),
193 v8::Integer::New(v8_isolate, script->line_offset()->value()), 193 v8::Integer::New(v8_isolate, script->line_offset()->value()),
194 v8::Integer::New(v8_isolate, script->column_offset()->value()), 194 v8::Integer::New(v8_isolate, script->column_offset()->value()),
195 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()), 195 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()),
196 v8::Integer::New(v8_isolate, script->id()->value()), 196 v8::Integer::New(v8_isolate, script->id()->value()),
197 v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()), 197 v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()),
198 Utils::ToLocal(source_map_url)); 198 Utils::ToLocal(source_map_url),
199 v8::Boolean::New(v8_isolate, script->is_opaque()));
199 return origin; 200 return origin;
200 } 201 }
201 202
202 203
203 // --- E x c e p t i o n B e h a v i o r --- 204 // --- E x c e p t i o n B e h a v i o r ---
204 205
205 206
206 void i::FatalProcessOutOfMemory(const char* location) { 207 void i::FatalProcessOutOfMemory(const char* location) {
207 i::V8::FatalProcessOutOfMemory(location, false); 208 i::V8::FatalProcessOutOfMemory(location, false);
208 } 209 }
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 } 1709 }
1709 1710
1710 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); 1711 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
1711 i::Handle<i::SharedFunctionInfo> result; 1712 i::Handle<i::SharedFunctionInfo> result;
1712 { 1713 {
1713 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); 1714 i::HistogramTimerScope total(isolate->counters()->compile_script(), true);
1714 i::Handle<i::Object> name_obj; 1715 i::Handle<i::Object> name_obj;
1715 i::Handle<i::Object> source_map_url; 1716 i::Handle<i::Object> source_map_url;
1716 int line_offset = 0; 1717 int line_offset = 0;
1717 int column_offset = 0; 1718 int column_offset = 0;
1718 bool is_embedder_debug_script = false;
1719 bool is_shared_cross_origin = false;
1720 if (!source->resource_name.IsEmpty()) { 1719 if (!source->resource_name.IsEmpty()) {
1721 name_obj = Utils::OpenHandle(*(source->resource_name)); 1720 name_obj = Utils::OpenHandle(*(source->resource_name));
1722 } 1721 }
1723 if (!source->resource_line_offset.IsEmpty()) { 1722 if (!source->resource_line_offset.IsEmpty()) {
1724 line_offset = static_cast<int>(source->resource_line_offset->Value()); 1723 line_offset = static_cast<int>(source->resource_line_offset->Value());
1725 } 1724 }
1726 if (!source->resource_column_offset.IsEmpty()) { 1725 if (!source->resource_column_offset.IsEmpty()) {
1727 column_offset = 1726 column_offset =
1728 static_cast<int>(source->resource_column_offset->Value()); 1727 static_cast<int>(source->resource_column_offset->Value());
1729 } 1728 }
1730 if (!source->resource_is_shared_cross_origin.IsEmpty()) {
1731 is_shared_cross_origin =
1732 source->resource_is_shared_cross_origin->IsTrue();
1733 }
1734 if (!source->resource_is_embedder_debug_script.IsEmpty()) {
1735 is_embedder_debug_script =
1736 source->resource_is_embedder_debug_script->IsTrue();
1737 }
1738 if (!source->source_map_url.IsEmpty()) { 1729 if (!source->source_map_url.IsEmpty()) {
1739 source_map_url = Utils::OpenHandle(*(source->source_map_url)); 1730 source_map_url = Utils::OpenHandle(*(source->source_map_url));
1740 } 1731 }
1741 result = i::Compiler::CompileScript( 1732 result = i::Compiler::CompileScript(
1742 str, name_obj, line_offset, column_offset, is_embedder_debug_script, 1733 str, name_obj, line_offset, column_offset, source->resource_options,
1743 is_shared_cross_origin, source_map_url, isolate->native_context(), NULL, 1734 source_map_url, isolate->native_context(), NULL, &script_data, options,
1744 &script_data, options, i::NOT_NATIVES_CODE, is_module); 1735 i::NOT_NATIVES_CODE, is_module);
1745 has_pending_exception = result.is_null(); 1736 has_pending_exception = result.is_null();
1746 if (has_pending_exception && script_data != NULL) { 1737 if (has_pending_exception && script_data != NULL) {
1747 // This case won't happen during normal operation; we have compiled 1738 // This case won't happen during normal operation; we have compiled
1748 // successfully and produced cached data, and but the second compilation 1739 // successfully and produced cached data, and but the second compilation
1749 // of the same source code fails. 1740 // of the same source code fails.
1750 delete script_data; 1741 delete script_data;
1751 script_data = NULL; 1742 script_data = NULL;
1752 } 1743 }
1753 RETURN_ON_FAILED_EXECUTION(UnboundScript); 1744 RETURN_ON_FAILED_EXECUTION(UnboundScript);
1754 1745
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); 1959 script->set_name(*Utils::OpenHandle(*(origin.ResourceName())));
1969 } 1960 }
1970 if (!origin.ResourceLineOffset().IsEmpty()) { 1961 if (!origin.ResourceLineOffset().IsEmpty()) {
1971 script->set_line_offset(i::Smi::FromInt( 1962 script->set_line_offset(i::Smi::FromInt(
1972 static_cast<int>(origin.ResourceLineOffset()->Value()))); 1963 static_cast<int>(origin.ResourceLineOffset()->Value())));
1973 } 1964 }
1974 if (!origin.ResourceColumnOffset().IsEmpty()) { 1965 if (!origin.ResourceColumnOffset().IsEmpty()) {
1975 script->set_column_offset(i::Smi::FromInt( 1966 script->set_column_offset(i::Smi::FromInt(
1976 static_cast<int>(origin.ResourceColumnOffset()->Value()))); 1967 static_cast<int>(origin.ResourceColumnOffset()->Value())));
1977 } 1968 }
1978 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { 1969 script->set_is_shared_cross_origin(origin.Options().IsSharedCrossOrigin());
1979 script->set_is_shared_cross_origin( 1970 script->set_is_opaque(origin.Options().IsOpaque());
1980 origin.ResourceIsSharedCrossOrigin()->IsTrue()); 1971 script->set_is_embedder_debug_script(
1981 } 1972 origin.Options().IsEmbedderDebugScript());
Yang 2015/05/18 07:23:33 V8 doesn't use those flags internally, so there is
horo 2015/05/18 10:19:23 Done.
1982 if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) {
1983 script->set_is_embedder_debug_script(
1984 origin.ResourceIsEmbedderDebugScript()->IsTrue());
1985 }
1986 if (!origin.SourceMapUrl().IsEmpty()) { 1973 if (!origin.SourceMapUrl().IsEmpty()) {
1987 script->set_source_mapping_url( 1974 script->set_source_mapping_url(
1988 *Utils::OpenHandle(*(origin.SourceMapUrl()))); 1975 *Utils::OpenHandle(*(origin.SourceMapUrl())));
1989 } 1976 }
1990 1977
1991 source->info->set_script(script); 1978 source->info->set_script(script);
1992 source->info->set_context(isolate->native_context()); 1979 source->info->set_context(isolate->native_context());
1993 1980
1994 // Do the parsing tasks which need to be done on the main thread. This will 1981 // Do the parsing tasks which need to be done on the main thread. This will
1995 // also handle parse errors. 1982 // also handle parse errors.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 2344
2358 bool Message::IsSharedCrossOrigin() const { 2345 bool Message::IsSharedCrossOrigin() const {
2359 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2346 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2360 ENTER_V8(isolate); 2347 ENTER_V8(isolate);
2361 auto self = Utils::OpenHandle(this); 2348 auto self = Utils::OpenHandle(this);
2362 auto script = i::Handle<i::JSValue>::cast( 2349 auto script = i::Handle<i::JSValue>::cast(
2363 i::Handle<i::Object>(self->script(), isolate)); 2350 i::Handle<i::Object>(self->script(), isolate));
2364 return i::Script::cast(script->value())->is_shared_cross_origin(); 2351 return i::Script::cast(script->value())->is_shared_cross_origin();
2365 } 2352 }
2366 2353
2354 bool Message::IsOpaque() const {
2355 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2356 ENTER_V8(isolate);
2357 auto self = Utils::OpenHandle(this);
2358 auto script = i::Handle<i::JSValue>::cast(
2359 i::Handle<i::Object>(self->script(), isolate));
2360 return i::Script::cast(script->value())->is_opaque();
2361 }
2362
2367 2363
2368 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { 2364 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const {
2369 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); 2365 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String);
2370 i::Handle<i::Object> result; 2366 i::Handle<i::Object> result;
2371 has_pending_exception = 2367 has_pending_exception =
2372 !CallV8HeapFunction(isolate, "$messageGetSourceLine", 2368 !CallV8HeapFunction(isolate, "$messageGetSourceLine",
2373 Utils::OpenHandle(this)).ToHandle(&result); 2369 Utils::OpenHandle(this)).ToHandle(&result);
2374 RETURN_ON_FAILED_EXECUTION(String); 2370 RETURN_ON_FAILED_EXECUTION(String);
2375 Local<String> str; 2371 Local<String> str;
2376 if (result->IsString()) { 2372 if (result->IsString()) {
(...skipping 5658 matching lines...) Expand 10 before | Expand all | Expand 10 after
8035 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8031 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8036 Address callback_address = 8032 Address callback_address =
8037 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8033 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8038 VMState<EXTERNAL> state(isolate); 8034 VMState<EXTERNAL> state(isolate);
8039 ExternalCallbackScope call_scope(isolate, callback_address); 8035 ExternalCallbackScope call_scope(isolate, callback_address);
8040 callback(info); 8036 callback(info);
8041 } 8037 }
8042 8038
8043 8039
8044 } } // namespace v8::internal 8040 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | src/compilation-cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698