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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 | 1595 |
1596 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); | 1596 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); |
1597 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); | 1597 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); |
1598 ENTER_V8(isolate); | 1598 ENTER_V8(isolate); |
1599 i::SharedFunctionInfo* raw_result = NULL; | 1599 i::SharedFunctionInfo* raw_result = NULL; |
1600 { i::HandleScope scope(isolate); | 1600 { i::HandleScope scope(isolate); |
1601 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); | 1601 i::HistogramTimerScope total(isolate->counters()->compile_script(), true); |
1602 i::Handle<i::Object> name_obj; | 1602 i::Handle<i::Object> name_obj; |
1603 int line_offset = 0; | 1603 int line_offset = 0; |
1604 int column_offset = 0; | 1604 int column_offset = 0; |
| 1605 bool is_embedder_debug_script = false; |
1605 bool is_shared_cross_origin = false; | 1606 bool is_shared_cross_origin = false; |
1606 if (!source->resource_name.IsEmpty()) { | 1607 if (!source->resource_name.IsEmpty()) { |
1607 name_obj = Utils::OpenHandle(*(source->resource_name)); | 1608 name_obj = Utils::OpenHandle(*(source->resource_name)); |
1608 } | 1609 } |
1609 if (!source->resource_line_offset.IsEmpty()) { | 1610 if (!source->resource_line_offset.IsEmpty()) { |
1610 line_offset = static_cast<int>(source->resource_line_offset->Value()); | 1611 line_offset = static_cast<int>(source->resource_line_offset->Value()); |
1611 } | 1612 } |
1612 if (!source->resource_column_offset.IsEmpty()) { | 1613 if (!source->resource_column_offset.IsEmpty()) { |
1613 column_offset = | 1614 column_offset = |
1614 static_cast<int>(source->resource_column_offset->Value()); | 1615 static_cast<int>(source->resource_column_offset->Value()); |
1615 } | 1616 } |
1616 if (!source->resource_is_shared_cross_origin.IsEmpty()) { | 1617 if (!source->resource_is_shared_cross_origin.IsEmpty()) { |
1617 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | |
1618 is_shared_cross_origin = | 1618 is_shared_cross_origin = |
1619 source->resource_is_shared_cross_origin == v8::True(v8_isolate); | 1619 source->resource_is_shared_cross_origin->IsTrue(); |
| 1620 } |
| 1621 if (!source->resource_is_embedder_debug_script.IsEmpty()) { |
| 1622 is_embedder_debug_script = |
| 1623 source->resource_is_embedder_debug_script->IsTrue(); |
1620 } | 1624 } |
1621 EXCEPTION_PREAMBLE(isolate); | 1625 EXCEPTION_PREAMBLE(isolate); |
1622 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( | 1626 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( |
1623 str, name_obj, line_offset, column_offset, is_shared_cross_origin, | 1627 str, name_obj, line_offset, column_offset, is_embedder_debug_script, |
1624 isolate->native_context(), NULL, &script_data, options, | 1628 is_shared_cross_origin, isolate->native_context(), NULL, &script_data, |
1625 i::NOT_NATIVES_CODE); | 1629 options, i::NOT_NATIVES_CODE); |
1626 has_pending_exception = result.is_null(); | 1630 has_pending_exception = result.is_null(); |
1627 if (has_pending_exception && script_data != NULL) { | 1631 if (has_pending_exception && script_data != NULL) { |
1628 // This case won't happen during normal operation; we have compiled | 1632 // This case won't happen during normal operation; we have compiled |
1629 // successfully and produced cached data, and but the second compilation | 1633 // successfully and produced cached data, and but the second compilation |
1630 // of the same source code fails. | 1634 // of the same source code fails. |
1631 delete script_data; | 1635 delete script_data; |
1632 script_data = NULL; | 1636 script_data = NULL; |
1633 } | 1637 } |
1634 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); | 1638 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); |
1635 raw_result = *result; | 1639 raw_result = *result; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 } | 1697 } |
1694 if (!origin.ResourceLineOffset().IsEmpty()) { | 1698 if (!origin.ResourceLineOffset().IsEmpty()) { |
1695 script->set_line_offset(i::Smi::FromInt( | 1699 script->set_line_offset(i::Smi::FromInt( |
1696 static_cast<int>(origin.ResourceLineOffset()->Value()))); | 1700 static_cast<int>(origin.ResourceLineOffset()->Value()))); |
1697 } | 1701 } |
1698 if (!origin.ResourceColumnOffset().IsEmpty()) { | 1702 if (!origin.ResourceColumnOffset().IsEmpty()) { |
1699 script->set_column_offset(i::Smi::FromInt( | 1703 script->set_column_offset(i::Smi::FromInt( |
1700 static_cast<int>(origin.ResourceColumnOffset()->Value()))); | 1704 static_cast<int>(origin.ResourceColumnOffset()->Value()))); |
1701 } | 1705 } |
1702 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { | 1706 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { |
1703 script->set_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin() == | 1707 script->set_is_shared_cross_origin( |
1704 v8::True(v8_isolate)); | 1708 origin.ResourceIsSharedCrossOrigin()->IsTrue()); |
| 1709 } |
| 1710 if (!origin.ResourceIsEmbedderDebugScript().IsEmpty()) { |
| 1711 script->set_is_embedder_debug_script( |
| 1712 origin.ResourceIsEmbedderDebugScript()->IsTrue()); |
1705 } | 1713 } |
1706 source->info->set_script(script); | 1714 source->info->set_script(script); |
1707 source->info->SetContext(isolate->native_context()); | 1715 source->info->SetContext(isolate->native_context()); |
1708 | 1716 |
1709 EXCEPTION_PREAMBLE(isolate); | 1717 EXCEPTION_PREAMBLE(isolate); |
1710 | 1718 |
1711 // Do the parsing tasks which need to be done on the main thread. This will | 1719 // Do the parsing tasks which need to be done on the main thread. This will |
1712 // also handle parse errors. | 1720 // also handle parse errors. |
1713 source->parser->Internalize(); | 1721 source->parser->Internalize(); |
1714 source->parser->HandleSourceURLComments(); | 1722 source->parser->HandleSourceURLComments(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 i::Handle<i::JSValue> script_value = | 1967 i::Handle<i::JSValue> script_value = |
1960 i::Handle<i::JSValue>::cast(script_wraper); | 1968 i::Handle<i::JSValue>::cast(script_wraper); |
1961 i::Handle<i::Script> script(i::Script::cast(script_value->value())); | 1969 i::Handle<i::Script> script(i::Script::cast(script_value->value())); |
1962 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); | 1970 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
1963 v8::Isolate* v8_isolate = | 1971 v8::Isolate* v8_isolate = |
1964 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); | 1972 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); |
1965 v8::ScriptOrigin origin( | 1973 v8::ScriptOrigin origin( |
1966 Utils::ToLocal(scriptName), | 1974 Utils::ToLocal(scriptName), |
1967 v8::Integer::New(v8_isolate, script->line_offset()->value()), | 1975 v8::Integer::New(v8_isolate, script->line_offset()->value()), |
1968 v8::Integer::New(v8_isolate, script->column_offset()->value()), | 1976 v8::Integer::New(v8_isolate, script->column_offset()->value()), |
1969 Handle<Boolean>(), | 1977 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()), |
1970 v8::Integer::New(v8_isolate, script->id()->value())); | 1978 v8::Integer::New(v8_isolate, script->id()->value()), |
| 1979 v8::Boolean::New(v8_isolate, script->is_embedder_debug_script())); |
1971 return origin; | 1980 return origin; |
1972 } | 1981 } |
1973 | 1982 |
1974 | 1983 |
1975 v8::Handle<Value> Message::GetScriptResourceName() const { | 1984 v8::Handle<Value> Message::GetScriptResourceName() const { |
1976 return GetScriptOrigin().ResourceName(); | 1985 return GetScriptOrigin().ResourceName(); |
1977 } | 1986 } |
1978 | 1987 |
1979 | 1988 |
1980 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 1989 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4130 | 4139 |
4131 ScriptOrigin Function::GetScriptOrigin() const { | 4140 ScriptOrigin Function::GetScriptOrigin() const { |
4132 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4141 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4133 if (func->shared()->script()->IsScript()) { | 4142 if (func->shared()->script()->IsScript()) { |
4134 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4143 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4135 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script); | 4144 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script); |
4136 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); | 4145 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); |
4137 v8::ScriptOrigin origin( | 4146 v8::ScriptOrigin origin( |
4138 Utils::ToLocal(scriptName), | 4147 Utils::ToLocal(scriptName), |
4139 v8::Integer::New(isolate, script->line_offset()->value()), | 4148 v8::Integer::New(isolate, script->line_offset()->value()), |
4140 v8::Integer::New(isolate, script->column_offset()->value())); | 4149 v8::Integer::New(isolate, script->column_offset()->value()), |
| 4150 v8::Boolean::New(isolate, script->is_shared_cross_origin()), |
| 4151 v8::Integer::New(isolate, script->id()->value()), |
| 4152 v8::Boolean::New(isolate, script->is_embedder_debug_script())); |
4141 return origin; | 4153 return origin; |
4142 } | 4154 } |
4143 return v8::ScriptOrigin(Handle<Value>()); | 4155 return v8::ScriptOrigin(Handle<Value>()); |
4144 } | 4156 } |
4145 | 4157 |
4146 | 4158 |
4147 const int Function::kLineOffsetNotFound = -1; | 4159 const int Function::kLineOffsetNotFound = -1; |
4148 | 4160 |
4149 | 4161 |
4150 int Function::GetScriptLineNumber() const { | 4162 int Function::GetScriptLineNumber() const { |
(...skipping 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7657 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7669 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7658 Address callback_address = | 7670 Address callback_address = |
7659 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7671 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7660 VMState<EXTERNAL> state(isolate); | 7672 VMState<EXTERNAL> state(isolate); |
7661 ExternalCallbackScope call_scope(isolate, callback_address); | 7673 ExternalCallbackScope call_scope(isolate, callback_address); |
7662 callback(info); | 7674 callback(info); |
7663 } | 7675 } |
7664 | 7676 |
7665 | 7677 |
7666 } } // namespace v8::internal | 7678 } } // namespace v8::internal |
OLD | NEW |