| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 return new i::ScriptDataImpl( | 1609 return new i::ScriptDataImpl( |
| 1610 i::Vector<unsigned>(deserialized_data, deserialized_data_length)); | 1610 i::Vector<unsigned>(deserialized_data, deserialized_data_length)); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 | 1613 |
| 1614 // --- S c r i p t --- | 1614 // --- S c r i p t --- |
| 1615 | 1615 |
| 1616 | 1616 |
| 1617 Local<Script> Script::New(v8::Handle<String> source, | 1617 Local<Script> Script::New(v8::Handle<String> source, |
| 1618 v8::ScriptOrigin* origin, | 1618 v8::ScriptOrigin* origin, |
| 1619 v8::ScriptData* pre_data, | 1619 v8::ScriptData* pre_data) { |
| 1620 v8::Handle<String> script_data) { | |
| 1621 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1620 i::Handle<i::String> str = Utils::OpenHandle(*source); |
| 1622 i::Isolate* isolate = str->GetIsolate(); | 1621 i::Isolate* isolate = str->GetIsolate(); |
| 1623 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); | 1622 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); |
| 1624 LOG_API(isolate, "Script::New"); | 1623 LOG_API(isolate, "Script::New"); |
| 1625 ENTER_V8(isolate); | 1624 ENTER_V8(isolate); |
| 1626 i::SharedFunctionInfo* raw_result = NULL; | 1625 i::SharedFunctionInfo* raw_result = NULL; |
| 1627 { i::HandleScope scope(isolate); | 1626 { i::HandleScope scope(isolate); |
| 1628 i::Handle<i::Object> name_obj; | 1627 i::Handle<i::Object> name_obj; |
| 1629 int line_offset = 0; | 1628 int line_offset = 0; |
| 1630 int column_offset = 0; | 1629 int column_offset = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1658 } | 1657 } |
| 1659 i::Handle<i::SharedFunctionInfo> result = | 1658 i::Handle<i::SharedFunctionInfo> result = |
| 1660 i::Compiler::CompileScript(str, | 1659 i::Compiler::CompileScript(str, |
| 1661 name_obj, | 1660 name_obj, |
| 1662 line_offset, | 1661 line_offset, |
| 1663 column_offset, | 1662 column_offset, |
| 1664 is_shared_cross_origin, | 1663 is_shared_cross_origin, |
| 1665 isolate->global_context(), | 1664 isolate->global_context(), |
| 1666 NULL, | 1665 NULL, |
| 1667 pre_data_impl, | 1666 pre_data_impl, |
| 1668 Utils::OpenHandle(*script_data, true), | |
| 1669 i::NOT_NATIVES_CODE); | 1667 i::NOT_NATIVES_CODE); |
| 1670 has_pending_exception = result.is_null(); | 1668 has_pending_exception = result.is_null(); |
| 1671 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); | 1669 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); |
| 1672 raw_result = *result; | 1670 raw_result = *result; |
| 1673 } | 1671 } |
| 1674 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); | 1672 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); |
| 1675 return ToApiHandle<Script>(result); | 1673 return ToApiHandle<Script>(result); |
| 1676 } | 1674 } |
| 1677 | 1675 |
| 1678 | 1676 |
| 1679 Local<Script> Script::New(v8::Handle<String> source, | 1677 Local<Script> Script::New(v8::Handle<String> source, |
| 1680 v8::Handle<Value> file_name) { | 1678 v8::Handle<Value> file_name) { |
| 1681 ScriptOrigin origin(file_name); | 1679 ScriptOrigin origin(file_name); |
| 1682 return New(source, &origin); | 1680 return New(source, &origin); |
| 1683 } | 1681 } |
| 1684 | 1682 |
| 1685 | 1683 |
| 1686 Local<Script> Script::Compile(v8::Handle<String> source, | 1684 Local<Script> Script::Compile(v8::Handle<String> source, |
| 1687 v8::ScriptOrigin* origin, | 1685 v8::ScriptOrigin* origin, |
| 1688 v8::ScriptData* pre_data, | 1686 v8::ScriptData* pre_data) { |
| 1689 v8::Handle<String> script_data) { | |
| 1690 i::Handle<i::String> str = Utils::OpenHandle(*source); | 1687 i::Handle<i::String> str = Utils::OpenHandle(*source); |
| 1691 i::Isolate* isolate = str->GetIsolate(); | 1688 i::Isolate* isolate = str->GetIsolate(); |
| 1692 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>()); | 1689 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>()); |
| 1693 LOG_API(isolate, "Script::Compile"); | 1690 LOG_API(isolate, "Script::Compile"); |
| 1694 ENTER_V8(isolate); | 1691 ENTER_V8(isolate); |
| 1695 Local<Script> generic = New(source, origin, pre_data, script_data); | 1692 Local<Script> generic = New(source, origin, pre_data); |
| 1696 if (generic.IsEmpty()) | 1693 if (generic.IsEmpty()) |
| 1697 return generic; | 1694 return generic; |
| 1698 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); | 1695 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); |
| 1699 i::Handle<i::SharedFunctionInfo> function = | 1696 i::Handle<i::SharedFunctionInfo> function = |
| 1700 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1697 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
| 1701 i::Handle<i::JSFunction> result = | 1698 i::Handle<i::JSFunction> result = |
| 1702 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1699 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1703 function, | 1700 function, |
| 1704 isolate->global_context()); | 1701 isolate->global_context()); |
| 1705 return ToApiHandle<Script>(result); | 1702 return ToApiHandle<Script>(result); |
| 1706 } | 1703 } |
| 1707 | 1704 |
| 1708 | 1705 |
| 1709 Local<Script> Script::Compile(v8::Handle<String> source, | 1706 Local<Script> Script::Compile(v8::Handle<String> source, |
| 1710 v8::Handle<Value> file_name, | 1707 v8::Handle<Value> file_name) { |
| 1711 v8::Handle<String> script_data) { | |
| 1712 ScriptOrigin origin(file_name); | 1708 ScriptOrigin origin(file_name); |
| 1713 return Compile(source, &origin, 0, script_data); | 1709 return Compile(source, &origin); |
| 1714 } | 1710 } |
| 1715 | 1711 |
| 1716 | 1712 |
| 1717 Local<Value> Script::Run() { | 1713 Local<Value> Script::Run() { |
| 1718 // If execution is terminating, Compile(script)->Run() requires this check. | 1714 // If execution is terminating, Compile(script)->Run() requires this check. |
| 1719 if (this == NULL) return Local<Value>(); | 1715 if (this == NULL) return Local<Value>(); |
| 1720 i::Handle<i::HeapObject> obj = | 1716 i::Handle<i::HeapObject> obj = |
| 1721 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1717 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1722 i::Isolate* isolate = obj->GetIsolate(); | 1718 i::Isolate* isolate = obj->GetIsolate(); |
| 1723 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); | 1719 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 LOG_API(isolate, "Script::GetName"); | 1798 LOG_API(isolate, "Script::GetName"); |
| 1803 if (obj->IsScript()) { | 1799 if (obj->IsScript()) { |
| 1804 i::Object* name = i::Script::cast(*obj)->name(); | 1800 i::Object* name = i::Script::cast(*obj)->name(); |
| 1805 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); | 1801 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); |
| 1806 } else { | 1802 } else { |
| 1807 return Handle<String>(); | 1803 return Handle<String>(); |
| 1808 } | 1804 } |
| 1809 } | 1805 } |
| 1810 | 1806 |
| 1811 | 1807 |
| 1812 void Script::SetData(v8::Handle<String> data) { | |
| 1813 i::Handle<i::HeapObject> obj = | |
| 1814 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | |
| 1815 i::Isolate* isolate = obj->GetIsolate(); | |
| 1816 ON_BAILOUT(isolate, "v8::Script::SetData()", return); | |
| 1817 LOG_API(isolate, "Script::SetData"); | |
| 1818 { | |
| 1819 i::HandleScope scope(isolate); | |
| 1820 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); | |
| 1821 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); | |
| 1822 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | |
| 1823 script->set_data(*raw_data); | |
| 1824 } | |
| 1825 } | |
| 1826 | |
| 1827 | |
| 1828 // --- E x c e p t i o n s --- | 1808 // --- E x c e p t i o n s --- |
| 1829 | 1809 |
| 1830 | 1810 |
| 1831 v8::TryCatch::TryCatch() | 1811 v8::TryCatch::TryCatch() |
| 1832 : isolate_(i::Isolate::Current()), | 1812 : isolate_(i::Isolate::Current()), |
| 1833 next_(isolate_->try_catch_handler_address()), | 1813 next_(isolate_->try_catch_handler_address()), |
| 1834 is_verbose_(false), | 1814 is_verbose_(false), |
| 1835 can_continue_(true), | 1815 can_continue_(true), |
| 1836 capture_message_(true), | 1816 capture_message_(true), |
| 1837 rethrow_(false), | 1817 rethrow_(false), |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 // Return this.script.name. | 1953 // Return this.script.name. |
| 1974 i::Handle<i::JSValue> script = | 1954 i::Handle<i::JSValue> script = |
| 1975 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 1955 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
| 1976 isolate)); | 1956 isolate)); |
| 1977 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), | 1957 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), |
| 1978 isolate); | 1958 isolate); |
| 1979 return scope.Escape(Utils::ToLocal(resource_name)); | 1959 return scope.Escape(Utils::ToLocal(resource_name)); |
| 1980 } | 1960 } |
| 1981 | 1961 |
| 1982 | 1962 |
| 1983 v8::Handle<Value> Message::GetScriptData() const { | |
| 1984 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | |
| 1985 ENTER_V8(isolate); | |
| 1986 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | |
| 1987 i::Handle<i::JSMessageObject> message = | |
| 1988 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | |
| 1989 // Return this.script.data. | |
| 1990 i::Handle<i::JSValue> script = | |
| 1991 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | |
| 1992 isolate)); | |
| 1993 i::Handle<i::Object> data(i::Script::cast(script->value())->data(), isolate); | |
| 1994 return scope.Escape(Utils::ToLocal(data)); | |
| 1995 } | |
| 1996 | |
| 1997 | |
| 1998 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 1963 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
| 1999 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1964 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2000 ENTER_V8(isolate); | 1965 ENTER_V8(isolate); |
| 2001 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 1966 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2002 i::Handle<i::JSMessageObject> message = | 1967 i::Handle<i::JSMessageObject> message = |
| 2003 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 1968 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2004 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 1969 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
| 2005 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 1970 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); |
| 2006 i::Handle<i::JSArray> stackTrace = | 1971 i::Handle<i::JSArray> stackTrace = |
| 2007 i::Handle<i::JSArray>::cast(stackFramesObj); | 1972 i::Handle<i::JSArray>::cast(stackFramesObj); |
| (...skipping 5369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7377 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7342 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7378 Address callback_address = | 7343 Address callback_address = |
| 7379 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7344 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7380 VMState<EXTERNAL> state(isolate); | 7345 VMState<EXTERNAL> state(isolate); |
| 7381 ExternalCallbackScope call_scope(isolate, callback_address); | 7346 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7382 callback(info); | 7347 callback(info); |
| 7383 } | 7348 } |
| 7384 | 7349 |
| 7385 | 7350 |
| 7386 } } // namespace v8::internal | 7351 } } // namespace v8::internal |
| OLD | NEW |