Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: src/api.cc

Issue 181113008: Revert "Remove Script::SetData and the script_data parameter from Script::(Compile|New)." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) {
1620 i::Handle<i::String> str = Utils::OpenHandle(*source); 1621 i::Handle<i::String> str = Utils::OpenHandle(*source);
1621 i::Isolate* isolate = str->GetIsolate(); 1622 i::Isolate* isolate = str->GetIsolate();
1622 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); 1623 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
1623 LOG_API(isolate, "Script::New"); 1624 LOG_API(isolate, "Script::New");
1624 ENTER_V8(isolate); 1625 ENTER_V8(isolate);
1625 i::SharedFunctionInfo* raw_result = NULL; 1626 i::SharedFunctionInfo* raw_result = NULL;
1626 { i::HandleScope scope(isolate); 1627 { i::HandleScope scope(isolate);
1627 i::Handle<i::Object> name_obj; 1628 i::Handle<i::Object> name_obj;
1628 int line_offset = 0; 1629 int line_offset = 0;
1629 int column_offset = 0; 1630 int column_offset = 0;
(...skipping 27 matching lines...) Expand all
1657 } 1658 }
1658 i::Handle<i::SharedFunctionInfo> result = 1659 i::Handle<i::SharedFunctionInfo> result =
1659 i::Compiler::CompileScript(str, 1660 i::Compiler::CompileScript(str,
1660 name_obj, 1661 name_obj,
1661 line_offset, 1662 line_offset,
1662 column_offset, 1663 column_offset,
1663 is_shared_cross_origin, 1664 is_shared_cross_origin,
1664 isolate->global_context(), 1665 isolate->global_context(),
1665 NULL, 1666 NULL,
1666 pre_data_impl, 1667 pre_data_impl,
1668 Utils::OpenHandle(*script_data, true),
1667 i::NOT_NATIVES_CODE); 1669 i::NOT_NATIVES_CODE);
1668 has_pending_exception = result.is_null(); 1670 has_pending_exception = result.is_null();
1669 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>()); 1671 EXCEPTION_BAILOUT_CHECK(isolate, Local<Script>());
1670 raw_result = *result; 1672 raw_result = *result;
1671 } 1673 }
1672 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate); 1674 i::Handle<i::SharedFunctionInfo> result(raw_result, isolate);
1673 return ToApiHandle<Script>(result); 1675 return ToApiHandle<Script>(result);
1674 } 1676 }
1675 1677
1676 1678
1677 Local<Script> Script::New(v8::Handle<String> source, 1679 Local<Script> Script::New(v8::Handle<String> source,
1678 v8::Handle<Value> file_name) { 1680 v8::Handle<Value> file_name) {
1679 ScriptOrigin origin(file_name); 1681 ScriptOrigin origin(file_name);
1680 return New(source, &origin); 1682 return New(source, &origin);
1681 } 1683 }
1682 1684
1683 1685
1684 Local<Script> Script::Compile(v8::Handle<String> source, 1686 Local<Script> Script::Compile(v8::Handle<String> source,
1685 v8::ScriptOrigin* origin, 1687 v8::ScriptOrigin* origin,
1686 v8::ScriptData* pre_data) { 1688 v8::ScriptData* pre_data,
1689 v8::Handle<String> script_data) {
1687 i::Handle<i::String> str = Utils::OpenHandle(*source); 1690 i::Handle<i::String> str = Utils::OpenHandle(*source);
1688 i::Isolate* isolate = str->GetIsolate(); 1691 i::Isolate* isolate = str->GetIsolate();
1689 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>()); 1692 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>());
1690 LOG_API(isolate, "Script::Compile"); 1693 LOG_API(isolate, "Script::Compile");
1691 ENTER_V8(isolate); 1694 ENTER_V8(isolate);
1692 Local<Script> generic = New(source, origin, pre_data); 1695 Local<Script> generic = New(source, origin, pre_data, script_data);
1693 if (generic.IsEmpty()) 1696 if (generic.IsEmpty())
1694 return generic; 1697 return generic;
1695 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); 1698 i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1696 i::Handle<i::SharedFunctionInfo> function = 1699 i::Handle<i::SharedFunctionInfo> function =
1697 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1700 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1698 i::Handle<i::JSFunction> result = 1701 i::Handle<i::JSFunction> result =
1699 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1702 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1700 function, 1703 function,
1701 isolate->global_context()); 1704 isolate->global_context());
1702 return ToApiHandle<Script>(result); 1705 return ToApiHandle<Script>(result);
1703 } 1706 }
1704 1707
1705 1708
1706 Local<Script> Script::Compile(v8::Handle<String> source, 1709 Local<Script> Script::Compile(v8::Handle<String> source,
1707 v8::Handle<Value> file_name) { 1710 v8::Handle<Value> file_name,
1711 v8::Handle<String> script_data) {
1708 ScriptOrigin origin(file_name); 1712 ScriptOrigin origin(file_name);
1709 return Compile(source, &origin); 1713 return Compile(source, &origin, 0, script_data);
1710 } 1714 }
1711 1715
1712 1716
1713 Local<Value> Script::Run() { 1717 Local<Value> Script::Run() {
1714 // If execution is terminating, Compile(script)->Run() requires this check. 1718 // If execution is terminating, Compile(script)->Run() requires this check.
1715 if (this == NULL) return Local<Value>(); 1719 if (this == NULL) return Local<Value>();
1716 i::Handle<i::HeapObject> obj = 1720 i::Handle<i::HeapObject> obj =
1717 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); 1721 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1718 i::Isolate* isolate = obj->GetIsolate(); 1722 i::Isolate* isolate = obj->GetIsolate();
1719 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1723 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 LOG_API(isolate, "Script::GetName"); 1802 LOG_API(isolate, "Script::GetName");
1799 if (obj->IsScript()) { 1803 if (obj->IsScript()) {
1800 i::Object* name = i::Script::cast(*obj)->name(); 1804 i::Object* name = i::Script::cast(*obj)->name();
1801 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); 1805 return Utils::ToLocal(i::Handle<i::Object>(name, isolate));
1802 } else { 1806 } else {
1803 return Handle<String>(); 1807 return Handle<String>();
1804 } 1808 }
1805 } 1809 }
1806 1810
1807 1811
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
1808 // --- E x c e p t i o n s --- 1828 // --- E x c e p t i o n s ---
1809 1829
1810 1830
1811 v8::TryCatch::TryCatch() 1831 v8::TryCatch::TryCatch()
1812 : isolate_(i::Isolate::Current()), 1832 : isolate_(i::Isolate::Current()),
1813 next_(isolate_->try_catch_handler_address()), 1833 next_(isolate_->try_catch_handler_address()),
1814 is_verbose_(false), 1834 is_verbose_(false),
1815 can_continue_(true), 1835 can_continue_(true),
1816 capture_message_(true), 1836 capture_message_(true),
1817 rethrow_(false), 1837 rethrow_(false),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 // Return this.script.name. 1973 // Return this.script.name.
1954 i::Handle<i::JSValue> script = 1974 i::Handle<i::JSValue> script =
1955 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), 1975 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(),
1956 isolate)); 1976 isolate));
1957 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), 1977 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(),
1958 isolate); 1978 isolate);
1959 return scope.Escape(Utils::ToLocal(resource_name)); 1979 return scope.Escape(Utils::ToLocal(resource_name));
1960 } 1980 }
1961 1981
1962 1982
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
1963 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { 1998 v8::Handle<v8::StackTrace> Message::GetStackTrace() const {
1964 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1999 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1965 ENTER_V8(isolate); 2000 ENTER_V8(isolate);
1966 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2001 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
1967 i::Handle<i::JSMessageObject> message = 2002 i::Handle<i::JSMessageObject> message =
1968 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); 2003 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
1969 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); 2004 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
1970 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); 2005 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>();
1971 i::Handle<i::JSArray> stackTrace = 2006 i::Handle<i::JSArray> stackTrace =
1972 i::Handle<i::JSArray>::cast(stackFramesObj); 2007 i::Handle<i::JSArray>::cast(stackFramesObj);
(...skipping 5369 matching lines...) Expand 10 before | Expand all | Expand 10 after
7342 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7377 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7343 Address callback_address = 7378 Address callback_address =
7344 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7379 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7345 VMState<EXTERNAL> state(isolate); 7380 VMState<EXTERNAL> state(isolate);
7346 ExternalCallbackScope call_scope(isolate, callback_address); 7381 ExternalCallbackScope call_scope(isolate, callback_address);
7347 callback(info); 7382 callback(info);
7348 } 7383 }
7349 7384
7350 7385
7351 } } // namespace v8::internal 7386 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698