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