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()); |
191 v8::ScriptOrigin origin( | 192 v8::ScriptOrigin origin( |
192 Utils::ToLocal(scriptName), | 193 Utils::ToLocal(scriptName), |
193 v8::Integer::New(v8_isolate, script->line_offset()->value()), | 194 v8::Integer::New(v8_isolate, script->line_offset()->value()), |
194 v8::Integer::New(v8_isolate, script->column_offset()->value()), | 195 v8::Integer::New(v8_isolate, script->column_offset()->value()), |
195 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()), | 196 v8::Boolean::New(v8_isolate, options.IsSharedCrossOrigin()), |
196 v8::Integer::New(v8_isolate, script->id()->value()), | 197 v8::Integer::New(v8_isolate, script->id()->value()), |
197 v8::Boolean::New(v8_isolate, script->is_embedder_debug_script()), | 198 v8::Boolean::New(v8_isolate, options.IsEmbedderDebugScript()), |
198 Utils::ToLocal(source_map_url)); | 199 Utils::ToLocal(source_map_url), |
| 200 v8::Boolean::New(v8_isolate, options.IsOpaque())); |
199 return origin; | 201 return origin; |
200 } | 202 } |
201 | 203 |
202 | 204 |
203 // --- E x c e p t i o n B e h a v i o r --- | 205 // --- E x c e p t i o n B e h a v i o r --- |
204 | 206 |
205 | 207 |
206 void i::FatalProcessOutOfMemory(const char* location) { | 208 void i::FatalProcessOutOfMemory(const char* location) { |
207 i::V8::FatalProcessOutOfMemory(location, false); | 209 i::V8::FatalProcessOutOfMemory(location, false); |
208 } | 210 } |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1708 } | 1710 } |
1709 | 1711 |
1710 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); | 1712 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); |
1711 i::Handle<i::SharedFunctionInfo> result; | 1713 i::Handle<i::SharedFunctionInfo> result; |
1712 { | 1714 { |
1713 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); | 1715 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); |
1714 i::Handle<i::Object> name_obj; | 1716 i::Handle<i::Object> name_obj; |
1715 i::Handle<i::Object> source_map_url; | 1717 i::Handle<i::Object> source_map_url; |
1716 int line_offset = 0; | 1718 int line_offset = 0; |
1717 int column_offset = 0; | 1719 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 } | |
1738 if (!source->source_map_url.IsEmpty()) { | 1730 if (!source->source_map_url.IsEmpty()) { |
1739 source_map_url = Utils::OpenHandle(*(source->source_map_url)); | 1731 source_map_url = Utils::OpenHandle(*(source->source_map_url)); |
1740 } | 1732 } |
1741 result = i::Compiler::CompileScript( | 1733 result = i::Compiler::CompileScript( |
1742 str, name_obj, line_offset, column_offset, is_embedder_debug_script, | 1734 str, name_obj, line_offset, column_offset, source->resource_options, |
1743 is_shared_cross_origin, source_map_url, isolate->native_context(), NULL, | 1735 source_map_url, isolate->native_context(), NULL, &script_data, options, |
1744 &script_data, options, i::NOT_NATIVES_CODE, is_module); | 1736 i::NOT_NATIVES_CODE, is_module); |
1745 has_pending_exception = result.is_null(); | 1737 has_pending_exception = result.is_null(); |
1746 if (has_pending_exception && script_data != NULL) { | 1738 if (has_pending_exception && script_data != NULL) { |
1747 // This case won't happen during normal operation; we have compiled | 1739 // This case won't happen during normal operation; we have compiled |
1748 // successfully and produced cached data, and but the second compilation | 1740 // successfully and produced cached data, and but the second compilation |
1749 // of the same source code fails. | 1741 // of the same source code fails. |
1750 delete script_data; | 1742 delete script_data; |
1751 script_data = NULL; | 1743 script_data = NULL; |
1752 } | 1744 } |
1753 RETURN_ON_FAILED_EXECUTION(UnboundScript); | 1745 RETURN_ON_FAILED_EXECUTION(UnboundScript); |
1754 | 1746 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 1960 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
1969 } | 1961 } |
1970 if (!origin.ResourceLineOffset().IsEmpty()) { | 1962 if (!origin.ResourceLineOffset().IsEmpty()) { |
1971 script->set_line_offset(i::Smi::FromInt( | 1963 script->set_line_offset(i::Smi::FromInt( |
1972 static_cast<int>(origin.ResourceLineOffset()->Value()))); | 1964 static_cast<int>(origin.ResourceLineOffset()->Value()))); |
1973 } | 1965 } |
1974 if (!origin.ResourceColumnOffset().IsEmpty()) { | 1966 if (!origin.ResourceColumnOffset().IsEmpty()) { |
1975 script->set_column_offset(i::Smi::FromInt( | 1967 script->set_column_offset(i::Smi::FromInt( |
1976 static_cast<int>(origin.ResourceColumnOffset()->Value()))); | 1968 static_cast<int>(origin.ResourceColumnOffset()->Value()))); |
1977 } | 1969 } |
1978 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { | 1970 script->set_origin_options(origin.Options()); |
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 } | |
1986 if (!origin.SourceMapUrl().IsEmpty()) { | 1971 if (!origin.SourceMapUrl().IsEmpty()) { |
1987 script->set_source_mapping_url( | 1972 script->set_source_mapping_url( |
1988 *Utils::OpenHandle(*(origin.SourceMapUrl()))); | 1973 *Utils::OpenHandle(*(origin.SourceMapUrl()))); |
1989 } | 1974 } |
1990 | 1975 |
1991 source->info->set_script(script); | 1976 source->info->set_script(script); |
1992 source->info->set_context(isolate->native_context()); | 1977 source->info->set_context(isolate->native_context()); |
1993 | 1978 |
1994 // Do the parsing tasks which need to be done on the main thread. This will | 1979 // Do the parsing tasks which need to be done on the main thread. This will |
1995 // also handle parse errors. | 1980 // also handle parse errors. |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 return GetEndColumn(context).FromMaybe(default_value); | 2339 return GetEndColumn(context).FromMaybe(default_value); |
2355 } | 2340 } |
2356 | 2341 |
2357 | 2342 |
2358 bool Message::IsSharedCrossOrigin() const { | 2343 bool Message::IsSharedCrossOrigin() const { |
2359 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2344 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2360 ENTER_V8(isolate); | 2345 ENTER_V8(isolate); |
2361 auto self = Utils::OpenHandle(this); | 2346 auto self = Utils::OpenHandle(this); |
2362 auto script = i::Handle<i::JSValue>::cast( | 2347 auto script = i::Handle<i::JSValue>::cast( |
2363 i::Handle<i::Object>(self->script(), isolate)); | 2348 i::Handle<i::Object>(self->script(), isolate)); |
2364 return i::Script::cast(script->value())->is_shared_cross_origin(); | 2349 return i::Script::cast(script->value()) |
| 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(); |
2365 } | 2361 } |
2366 | 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); |
(...skipping 5660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |