OLD | NEW |
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 } // namespace | 182 } // namespace |
183 | 183 |
184 | 184 |
185 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, | 185 static ScriptOrigin GetScriptOriginForScript(i::Isolate* isolate, |
186 i::Handle<i::Script> script) { | 186 i::Handle<i::Script> script) { |
187 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); | 187 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
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 ScriptOriginOptions options(script->origin_options()); | |
192 v8::ScriptOrigin origin( | 191 v8::ScriptOrigin origin( |
193 Utils::ToLocal(scriptName), | 192 Utils::ToLocal(scriptName), |
194 v8::Integer::New(v8_isolate, script->line_offset()->value()), | 193 v8::Integer::New(v8_isolate, script->line_offset()->value()), |
195 v8::Integer::New(v8_isolate, script->column_offset()->value()), | 194 v8::Integer::New(v8_isolate, script->column_offset()->value()), |
196 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()), | 195 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()), |
197 v8::Integer::New(v8_isolate, script->id()->value()), | 196 v8::Integer::New(v8_isolate, script->id()->value()), |
198 v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()), | 197 v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()), |
199 Utils::ToLocal(source_map_url), | 198 Utils::ToLocal(source_map_url)); |
200 v8::Boolean::New(v8_isolate, options.IsOpaque())); | |
201 return origin; | 199 return origin; |
202 } | 200 } |
203 | 201 |
204 | 202 |
205 // --- E x c e p t i o n B e h a v i o r --- | 203 // --- E x c e p t i o n B e h a v i o r --- |
206 | 204 |
207 | 205 |
208 void i::FatalProcessOutOfMemory(const char* location) { | 206 void i::FatalProcessOutOfMemory(const char* location) { |
209 i::V8::FatalProcessOutOfMemory(location, false); | 207 i::V8::FatalProcessOutOfMemory(location, false); |
210 } | 208 } |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 } | 1708 } |
1711 | 1709 |
1712 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); | 1710 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); |
1713 i::Handle<i::SharedFunctionInfo> result; | 1711 i::Handle<i::SharedFunctionInfo> result; |
1714 { | 1712 { |
1715 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); | 1713 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); |
1716 i::Handle<i::Object> name_obj; | 1714 i::Handle<i::Object> name_obj; |
1717 i::Handle<i::Object> source_map_url; | 1715 i::Handle<i::Object> source_map_url; |
1718 int line_offset = 0; | 1716 int line_offset = 0; |
1719 int column_offset = 0; | 1717 int column_offset = 0; |
| 1718 bool is_embedder_debug_script = false; |
| 1719 bool is_shared_cross_origin = false; |
1720 if (!source->resource_name.IsEmpty()) { | 1720 if (!source->resource_name.IsEmpty()) { |
1721 name_obj = Utils::OpenHandle(*(source->resource_name)); | 1721 name_obj = Utils::OpenHandle(*(source->resource_name)); |
1722 } | 1722 } |
1723 if (!source->resource_line_offset.IsEmpty()) { | 1723 if (!source->resource_line_offset.IsEmpty()) { |
1724 line_offset = static_cast<int>(source->resource_line_offset->Value()); | 1724 line_offset = static_cast<int>(source->resource_line_offset->Value()); |
1725 } | 1725 } |
1726 if (!source->resource_column_offset.IsEmpty()) { | 1726 if (!source->resource_column_offset.IsEmpty()) { |
1727 column_offset = | 1727 column_offset = |
1728 static_cast<int>(source->resource_column_offset->Value()); | 1728 static_cast<int>(source->resource_column_offset->Value()); |
1729 } | 1729 } |
| 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 } |
1730 if (!source->source_map_url.IsEmpty()) { | 1738 if (!source->source_map_url.IsEmpty()) { |
1731 source_map_url = Utils::OpenHandle(*(source->source_map_url)); | 1739 source_map_url = Utils::OpenHandle(*(source->source_map_url)); |
1732 } | 1740 } |
1733 result = i::Compiler::CompileScript( | 1741 result = i::Compiler::CompileScript( |
1734 str, name_obj, line_offset, column_offset, source->resource_options, | 1742 str, name_obj, line_offset, column_offset, is_embedder_debug_script, |
1735 source_map_url, isolate->native_context(), NULL, &script_data, options, | 1743 is_shared_cross_origin, source_map_url, isolate->native_context(), NULL, |
1736 i::NOT_NATIVES_CODE, is_module); | 1744 &script_data, options, i::NOT_NATIVES_CODE, is_module); |
1737 has_pending_exception = result.is_null(); | 1745 has_pending_exception = result.is_null(); |
1738 if (has_pending_exception && script_data != NULL) { | 1746 if (has_pending_exception && script_data != NULL) { |
1739 // This case won't happen during normal operation; we have compiled | 1747 // This case won't happen during normal operation; we have compiled |
1740 // successfully and produced cached data, and but the second compilation | 1748 // successfully and produced cached data, and but the second compilation |
1741 // of the same source code fails. | 1749 // of the same source code fails. |
1742 delete script_data; | 1750 delete script_data; |
1743 script_data = NULL; | 1751 script_data = NULL; |
1744 } | 1752 } |
1745 RETURN_ON_FAILED_EXECUTION(UnboundScript); | 1753 RETURN_ON_FAILED_EXECUTION(UnboundScript); |
1746 | 1754 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 1968 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
1961 } | 1969 } |
1962 if (!origin.ResourceLineOffset().IsEmpty()) { | 1970 if (!origin.ResourceLineOffset().IsEmpty()) { |
1963 script->set_line_offset(i::Smi::FromInt( | 1971 script->set_line_offset(i::Smi::FromInt( |
1964 static_cast<int>(origin.ResourceLineOffset()->Value()))); | 1972 static_cast<int>(origin.ResourceLineOffset()->Value()))); |
1965 } | 1973 } |
1966 if (!origin.ResourceColumnOffset().IsEmpty()) { | 1974 if (!origin.ResourceColumnOffset().IsEmpty()) { |
1967 script->set_column_offset(i::Smi::FromInt( | 1975 script->set_column_offset(i::Smi::FromInt( |
1968 static_cast<int>(origin.ResourceColumnOffset()->Value()))); | 1976 static_cast<int>(origin.ResourceColumnOffset()->Value()))); |
1969 } | 1977 } |
1970 script->set_origin_options(origin.Options()); | 1978 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { |
| 1979 script->set_is_shared_cross_origin( |
| 1980 origin.ResourceIsSharedCrossOrigin()->IsTrue()); |
| 1981 } |
| 1982 if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) { |
| 1983 script->set_is_embedder_debug_script( |
| 1984 origin.ResourceIsEmbedderDebugScript()->IsTrue()); |
| 1985 } |
1971 if (!origin.SourceMapUrl().IsEmpty()) { | 1986 if (!origin.SourceMapUrl().IsEmpty()) { |
1972 script->set_source_mapping_url( | 1987 script->set_source_mapping_url( |
1973 *Utils::OpenHandle(*(origin.SourceMapUrl()))); | 1988 *Utils::OpenHandle(*(origin.SourceMapUrl()))); |
1974 } | 1989 } |
1975 | 1990 |
1976 source->info->set_script(script); | 1991 source->info->set_script(script); |
1977 source->info->set_context(isolate->native_context()); | 1992 source->info->set_context(isolate->native_context()); |
1978 | 1993 |
1979 // Do the parsing tasks which need to be done on the main thread. This will | 1994 // Do the parsing tasks which need to be done on the main thread. This will |
1980 // also handle parse errors. | 1995 // also handle parse errors. |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 return GetEndColumn(context).FromMaybe(default_value); | 2354 return GetEndColumn(context).FromMaybe(default_value); |
2340 } | 2355 } |
2341 | 2356 |
2342 | 2357 |
2343 bool Message::IsSharedCrossOrigin() const { | 2358 bool Message::IsSharedCrossOrigin() const { |
2344 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2359 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2345 ENTER_V8(isolate); | 2360 ENTER_V8(isolate); |
2346 auto self = Utils::OpenHandle(this); | 2361 auto self = Utils::OpenHandle(this); |
2347 auto script = i::Handle<i::JSValue>::cast( | 2362 auto script = i::Handle<i::JSValue>::cast( |
2348 i::Handle<i::Object>(self->script(), isolate)); | 2363 i::Handle<i::Object>(self->script(), isolate)); |
2349 return i::Script::cast(script->value()) | 2364 return i::Script::cast(script->value())->is_shared_cross_origin(); |
2350 ->origin_options() | |
2351 .IsSharedCrossOrigin(); | |
2352 } | |
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())->origin_options().IsOpaque(); | |
2361 } | 2365 } |
2362 | 2366 |
2363 | 2367 |
2364 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { | 2368 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
2365 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); | 2369 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); |
2366 i::Handle<i::Object> result; | 2370 i::Handle<i::Object> result; |
2367 has_pending_exception = | 2371 has_pending_exception = |
2368 !CallV8HeapFunction(isolate, "$messageGetSourceLine", | 2372 !CallV8HeapFunction(isolate, "$messageGetSourceLine", |
2369 Utils::OpenHandle(this)).ToHandle(&result); | 2373 Utils::OpenHandle(this)).ToHandle(&result); |
2370 RETURN_ON_FAILED_EXECUTION(String); | 2374 RETURN_ON_FAILED_EXECUTION(String); |
(...skipping 5660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8031 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8035 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
8032 Address callback_address = | 8036 Address callback_address = |
8033 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8037 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8034 VMState<EXTERNAL> state(isolate); | 8038 VMState<EXTERNAL> state(isolate); |
8035 ExternalCallbackScope call_scope(isolate, callback_address); | 8039 ExternalCallbackScope call_scope(isolate, callback_address); |
8036 callback(info); | 8040 callback(info); |
8037 } | 8041 } |
8038 | 8042 |
8039 | 8043 |
8040 } } // namespace v8::internal | 8044 } } // namespace v8::internal |
OLD | NEW |