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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1543 } | 1543 } |
1544 | 1544 |
1545 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); | 1545 i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string)); |
1546 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); | 1546 LOG_API(isolate, "ScriptCompiler::CompileUnbound"); |
1547 ENTER_V8(isolate); | 1547 ENTER_V8(isolate); |
1548 i::SharedFunctionInfo* raw_result = NULL; | 1548 i::SharedFunctionInfo* raw_result = NULL; |
1549 { i::HandleScope scope(isolate); | 1549 { i::HandleScope scope(isolate); |
1550 i::Handle<i::Object> name_obj; | 1550 i::Handle<i::Object> name_obj; |
1551 int line_offset = 0; | 1551 int line_offset = 0; |
1552 int column_offset = 0; | 1552 int column_offset = 0; |
1553 bool is_debugger_script = false; | |
1553 bool is_shared_cross_origin = false; | 1554 bool is_shared_cross_origin = false; |
1554 if (!source->resource_name.IsEmpty()) { | 1555 if (!source->resource_name.IsEmpty()) { |
1555 name_obj = Utils::OpenHandle(*(source->resource_name)); | 1556 name_obj = Utils::OpenHandle(*(source->resource_name)); |
1556 } | 1557 } |
1557 if (!source->resource_line_offset.IsEmpty()) { | 1558 if (!source->resource_line_offset.IsEmpty()) { |
1558 line_offset = static_cast<int>(source->resource_line_offset->Value()); | 1559 line_offset = static_cast<int>(source->resource_line_offset->Value()); |
1559 } | 1560 } |
1560 if (!source->resource_column_offset.IsEmpty()) { | 1561 if (!source->resource_column_offset.IsEmpty()) { |
1561 column_offset = | 1562 column_offset = |
1562 static_cast<int>(source->resource_column_offset->Value()); | 1563 static_cast<int>(source->resource_column_offset->Value()); |
1563 } | 1564 } |
1564 if (!source->resource_is_shared_cross_origin.IsEmpty()) { | 1565 if (!source->resource_is_shared_cross_origin.IsEmpty()) { |
1565 v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); | |
1566 is_shared_cross_origin = | 1566 is_shared_cross_origin = |
1567 source->resource_is_shared_cross_origin == v8::True(v8_isolate); | 1567 source->resource_is_shared_cross_origin->IsTrue(); |
1568 } | |
1569 if (!source->resource_is_debugger_script.IsEmpty()) { | |
1570 is_debugger_script = source->resource_is_debugger_script->IsTrue(); | |
1568 } | 1571 } |
1569 EXCEPTION_PREAMBLE(isolate); | 1572 EXCEPTION_PREAMBLE(isolate); |
1570 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( | 1573 i::Handle<i::SharedFunctionInfo> result = i::Compiler::CompileScript( |
1571 str, name_obj, line_offset, column_offset, is_shared_cross_origin, | 1574 str, name_obj, line_offset, column_offset, is_debugger_script, |
1572 isolate->native_context(), NULL, &script_data, options, | 1575 is_shared_cross_origin, isolate->native_context(), NULL, &script_data, |
1573 i::NOT_NATIVES_CODE); | 1576 options, i::NOT_NATIVES_CODE); |
1574 has_pending_exception = result.is_null(); | 1577 has_pending_exception = result.is_null(); |
1575 if (has_pending_exception && script_data != NULL) { | 1578 if (has_pending_exception && script_data != NULL) { |
1576 // This case won't happen during normal operation; we have compiled | 1579 // This case won't happen during normal operation; we have compiled |
1577 // successfully and produced cached data, and but the second compilation | 1580 // successfully and produced cached data, and but the second compilation |
1578 // of the same source code fails. | 1581 // of the same source code fails. |
1579 delete script_data; | 1582 delete script_data; |
1580 script_data = NULL; | 1583 script_data = NULL; |
1581 } | 1584 } |
1582 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); | 1585 EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>()); |
1583 raw_result = *result; | 1586 raw_result = *result; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1641 } | 1644 } |
1642 if (!origin.ResourceLineOffset().IsEmpty()) { | 1645 if (!origin.ResourceLineOffset().IsEmpty()) { |
1643 script->set_line_offset(i::Smi::FromInt( | 1646 script->set_line_offset(i::Smi::FromInt( |
1644 static_cast<int>(origin.ResourceLineOffset()->Value()))); | 1647 static_cast<int>(origin.ResourceLineOffset()->Value()))); |
1645 } | 1648 } |
1646 if (!origin.ResourceColumnOffset().IsEmpty()) { | 1649 if (!origin.ResourceColumnOffset().IsEmpty()) { |
1647 script->set_column_offset(i::Smi::FromInt( | 1650 script->set_column_offset(i::Smi::FromInt( |
1648 static_cast<int>(origin.ResourceColumnOffset()->Value()))); | 1651 static_cast<int>(origin.ResourceColumnOffset()->Value()))); |
1649 } | 1652 } |
1650 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { | 1653 if (!origin.ResourceIsSharedCrossOrigin().IsEmpty()) { |
1651 script->set_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin() == | 1654 script->set_is_shared_cross_origin( |
1652 v8::True(v8_isolate)); | 1655 origin.ResourceIsSharedCrossOrigin()->IsTrue()); |
1656 } | |
1657 if (!origin.ResourceIsDebuggerScript().IsEmpty()) { | |
1658 script->set_is_debugger_script( | |
1659 origin.ResourceIsDebuggerScript()->IsTrue()); | |
1653 } | 1660 } |
1654 source->info->set_script(script); | 1661 source->info->set_script(script); |
1655 source->info->SetContext(isolate->native_context()); | 1662 source->info->SetContext(isolate->native_context()); |
1656 | 1663 |
1657 EXCEPTION_PREAMBLE(isolate); | 1664 EXCEPTION_PREAMBLE(isolate); |
1658 | 1665 |
1659 // Do the parsing tasks which need to be done on the main thread. This will | 1666 // Do the parsing tasks which need to be done on the main thread. This will |
1660 // also handle parse errors. | 1667 // also handle parse errors. |
1661 source->parser->Internalize(); | 1668 source->parser->Internalize(); |
1662 source->parser->HandleSourceURLComments(); | 1669 source->parser->HandleSourceURLComments(); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1907 i::Handle<i::JSValue> script_value = | 1914 i::Handle<i::JSValue> script_value = |
1908 i::Handle<i::JSValue>::cast(script_wraper); | 1915 i::Handle<i::JSValue>::cast(script_wraper); |
1909 i::Handle<i::Script> script(i::Script::cast(script_value->value())); | 1916 i::Handle<i::Script> script(i::Script::cast(script_value->value())); |
1910 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); | 1917 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
1911 v8::Isolate* v8_isolate = | 1918 v8::Isolate* v8_isolate = |
1912 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); | 1919 reinterpret_cast<v8::Isolate*>(script->GetIsolate()); |
1913 v8::ScriptOrigin origin( | 1920 v8::ScriptOrigin origin( |
1914 Utils::ToLocal(scriptName), | 1921 Utils::ToLocal(scriptName), |
1915 v8::Integer::New(v8_isolate, script->line_offset()->value()), | 1922 v8::Integer::New(v8_isolate, script->line_offset()->value()), |
1916 v8::Integer::New(v8_isolate, script->column_offset()->value()), | 1923 v8::Integer::New(v8_isolate, script->column_offset()->value()), |
1917 Handle<Boolean>(), | 1924 v8::Boolean::New(v8_isolate, script->is_shared_cross_origin()), |
Yang
2015/01/28 14:02:04
This is great. I noticed that this is missing and
kozy
2015/01/29 10:52:56
Done.
| |
1918 v8::Integer::New(v8_isolate, script->id()->value())); | 1925 v8::Integer::New(v8_isolate, script->id()->value()), |
1926 v8::Boolean::New(v8_isolate, script->is_debugger_script())); | |
1919 return origin; | 1927 return origin; |
1920 } | 1928 } |
1921 | 1929 |
1922 | 1930 |
1923 v8::Handle<Value> Message::GetScriptResourceName() const { | 1931 v8::Handle<Value> Message::GetScriptResourceName() const { |
1924 return GetScriptOrigin().ResourceName(); | 1932 return GetScriptOrigin().ResourceName(); |
1925 } | 1933 } |
1926 | 1934 |
1927 | 1935 |
1928 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 1936 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4078 | 4086 |
4079 ScriptOrigin Function::GetScriptOrigin() const { | 4087 ScriptOrigin Function::GetScriptOrigin() const { |
4080 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4088 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4081 if (func->shared()->script()->IsScript()) { | 4089 if (func->shared()->script()->IsScript()) { |
4082 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4090 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4083 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script); | 4091 i::Handle<i::Object> scriptName = i::Script::GetNameOrSourceURL(script); |
4084 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); | 4092 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(func->GetIsolate()); |
4085 v8::ScriptOrigin origin( | 4093 v8::ScriptOrigin origin( |
4086 Utils::ToLocal(scriptName), | 4094 Utils::ToLocal(scriptName), |
4087 v8::Integer::New(isolate, script->line_offset()->value()), | 4095 v8::Integer::New(isolate, script->line_offset()->value()), |
4088 v8::Integer::New(isolate, script->column_offset()->value())); | 4096 v8::Integer::New(isolate, script->column_offset()->value())); |
Yang
2015/01/28 14:02:04
Can we fix this place as well?
kozy
2015/01/29 10:52:55
Done.
And checks added to test-api.cc
| |
4089 return origin; | 4097 return origin; |
4090 } | 4098 } |
4091 return v8::ScriptOrigin(Handle<Value>()); | 4099 return v8::ScriptOrigin(Handle<Value>()); |
4092 } | 4100 } |
4093 | 4101 |
4094 | 4102 |
4095 const int Function::kLineOffsetNotFound = -1; | 4103 const int Function::kLineOffsetNotFound = -1; |
4096 | 4104 |
4097 | 4105 |
4098 int Function::GetScriptLineNumber() const { | 4106 int Function::GetScriptLineNumber() const { |
(...skipping 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7605 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7613 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7606 Address callback_address = | 7614 Address callback_address = |
7607 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7615 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7608 VMState<EXTERNAL> state(isolate); | 7616 VMState<EXTERNAL> state(isolate); |
7609 ExternalCallbackScope call_scope(isolate, callback_address); | 7617 ExternalCallbackScope call_scope(isolate, callback_address); |
7610 callback(info); | 7618 callback(info); |
7611 } | 7619 } |
7612 | 7620 |
7613 | 7621 |
7614 } } // namespace v8::internal | 7622 } } // namespace v8::internal |
OLD | NEW |