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

Side by Side Diff: src/api.cc

Issue 145773008: A64: Synchronize with r17104. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/api.h ('k') | src/arguments.h » ('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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 // function to do the setting. 1639 // function to do the setting.
1640 EnsureConstructor(this); 1640 EnsureConstructor(this);
1641 } 1641 }
1642 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1642 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1643 } 1643 }
1644 1644
1645 1645
1646 // --- S c r i p t D a t a --- 1646 // --- S c r i p t D a t a ---
1647 1647
1648 1648
1649 ScriptData* ScriptData::PreCompile(const char* input, int length) { 1649 ScriptData* ScriptData::PreCompile(v8::Isolate* isolate,
1650 const char* input,
1651 int length) {
1650 i::Utf8ToUtf16CharacterStream stream( 1652 i::Utf8ToUtf16CharacterStream stream(
1651 reinterpret_cast<const unsigned char*>(input), length); 1653 reinterpret_cast<const unsigned char*>(input), length);
1652 return i::PreParserApi::PreParse(i::Isolate::Current(), &stream); 1654 return i::PreParserApi::PreParse(
1655 reinterpret_cast<i::Isolate*>(isolate), &stream);
1653 } 1656 }
1654 1657
1655 1658
1656 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1659 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1657 i::Handle<i::String> str = Utils::OpenHandle(*source); 1660 i::Handle<i::String> str = Utils::OpenHandle(*source);
1658 i::Isolate* isolate = str->GetIsolate(); 1661 i::Isolate* isolate = str->GetIsolate();
1659 if (str->IsExternalTwoByteString()) { 1662 if (str->IsExternalTwoByteString()) {
1660 i::ExternalTwoByteStringUtf16CharacterStream stream( 1663 i::ExternalTwoByteStringUtf16CharacterStream stream(
1661 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length()); 1664 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1662 return i::PreParserApi::PreParse(isolate, &stream); 1665 return i::PreParserApi::PreParse(isolate, &stream);
(...skipping 26 matching lines...) Expand all
1689 } 1692 }
1690 1693
1691 1694
1692 // --- S c r i p t --- 1695 // --- S c r i p t ---
1693 1696
1694 1697
1695 Local<Script> Script::New(v8::Handle<String> source, 1698 Local<Script> Script::New(v8::Handle<String> source,
1696 v8::ScriptOrigin* origin, 1699 v8::ScriptOrigin* origin,
1697 v8::ScriptData* pre_data, 1700 v8::ScriptData* pre_data,
1698 v8::Handle<String> script_data) { 1701 v8::Handle<String> script_data) {
1699 i::Isolate* isolate = i::Isolate::Current(); 1702 i::Handle<i::String> str = Utils::OpenHandle(*source);
1703 i::Isolate* isolate = str->GetIsolate();
1700 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>()); 1704 ON_BAILOUT(isolate, "v8::Script::New()", return Local<Script>());
1701 LOG_API(isolate, "Script::New"); 1705 LOG_API(isolate, "Script::New");
1702 ENTER_V8(isolate); 1706 ENTER_V8(isolate);
1703 i::SharedFunctionInfo* raw_result = NULL; 1707 i::SharedFunctionInfo* raw_result = NULL;
1704 { i::HandleScope scope(isolate); 1708 { i::HandleScope scope(isolate);
1705 i::Handle<i::String> str = Utils::OpenHandle(*source);
1706 i::Handle<i::Object> name_obj; 1709 i::Handle<i::Object> name_obj;
1707 int line_offset = 0; 1710 int line_offset = 0;
1708 int column_offset = 0; 1711 int column_offset = 0;
1709 bool is_shared_cross_origin = false; 1712 bool is_shared_cross_origin = false;
1710 if (origin != NULL) { 1713 if (origin != NULL) {
1711 if (!origin->ResourceName().IsEmpty()) { 1714 if (!origin->ResourceName().IsEmpty()) {
1712 name_obj = Utils::OpenHandle(*origin->ResourceName()); 1715 name_obj = Utils::OpenHandle(*origin->ResourceName());
1713 } 1716 }
1714 if (!origin->ResourceLineOffset().IsEmpty()) { 1717 if (!origin->ResourceLineOffset().IsEmpty()) {
1715 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value()); 1718 line_offset = static_cast<int>(origin->ResourceLineOffset()->Value());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 v8::Handle<Value> file_name) { 1761 v8::Handle<Value> file_name) {
1759 ScriptOrigin origin(file_name); 1762 ScriptOrigin origin(file_name);
1760 return New(source, &origin); 1763 return New(source, &origin);
1761 } 1764 }
1762 1765
1763 1766
1764 Local<Script> Script::Compile(v8::Handle<String> source, 1767 Local<Script> Script::Compile(v8::Handle<String> source,
1765 v8::ScriptOrigin* origin, 1768 v8::ScriptOrigin* origin,
1766 v8::ScriptData* pre_data, 1769 v8::ScriptData* pre_data,
1767 v8::Handle<String> script_data) { 1770 v8::Handle<String> script_data) {
1768 i::Isolate* isolate = i::Isolate::Current(); 1771 i::Handle<i::String> str = Utils::OpenHandle(*source);
1772 i::Isolate* isolate = str->GetIsolate();
1769 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>()); 1773 ON_BAILOUT(isolate, "v8::Script::Compile()", return Local<Script>());
1770 LOG_API(isolate, "Script::Compile"); 1774 LOG_API(isolate, "Script::Compile");
1771 ENTER_V8(isolate); 1775 ENTER_V8(isolate);
1772 Local<Script> generic = New(source, origin, pre_data, script_data); 1776 Local<Script> generic = New(source, origin, pre_data, script_data);
1773 if (generic.IsEmpty()) 1777 if (generic.IsEmpty())
1774 return generic; 1778 return generic;
1775 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); 1779 i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1776 i::Handle<i::SharedFunctionInfo> function = 1780 i::Handle<i::SharedFunctionInfo> function =
1777 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1781 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1778 i::Handle<i::JSFunction> result = 1782 i::Handle<i::JSFunction> result =
1779 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1783 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1780 function, 1784 function,
1781 isolate->global_context()); 1785 isolate->global_context());
1782 return ToApiHandle<Script>(result); 1786 return ToApiHandle<Script>(result);
1783 } 1787 }
1784 1788
1785 1789
1786 Local<Script> Script::Compile(v8::Handle<String> source, 1790 Local<Script> Script::Compile(v8::Handle<String> source,
1787 v8::Handle<Value> file_name, 1791 v8::Handle<Value> file_name,
1788 v8::Handle<String> script_data) { 1792 v8::Handle<String> script_data) {
1789 ScriptOrigin origin(file_name); 1793 ScriptOrigin origin(file_name);
1790 return Compile(source, &origin, 0, script_data); 1794 return Compile(source, &origin, 0, script_data);
1791 } 1795 }
1792 1796
1793 1797
1794 Local<Value> Script::Run() { 1798 Local<Value> Script::Run() {
1795 i::Isolate* isolate = i::Isolate::Current(); 1799 // If execution is terminating, Compile(script)->Run() requires this check.
1800 if (this == NULL) return Local<Value>();
1801 i::Handle<i::HeapObject> obj =
1802 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1803 i::Isolate* isolate = obj->GetIsolate();
1796 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1804 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1797 LOG_API(isolate, "Script::Run"); 1805 LOG_API(isolate, "Script::Run");
1798 ENTER_V8(isolate); 1806 ENTER_V8(isolate);
1799 i::Logger::TimerEventScope timer_scope( 1807 i::Logger::TimerEventScope timer_scope(
1800 isolate, i::Logger::TimerEventScope::v8_execute); 1808 isolate, i::Logger::TimerEventScope::v8_execute);
1801 i::Object* raw_result = NULL; 1809 i::Object* raw_result = NULL;
1802 { 1810 {
1803 i::HandleScope scope(isolate); 1811 i::HandleScope scope(isolate);
1804 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1805 i::Handle<i::JSFunction> fun; 1812 i::Handle<i::JSFunction> fun;
1806 if (obj->IsSharedFunctionInfo()) { 1813 if (obj->IsSharedFunctionInfo()) {
1807 i::Handle<i::SharedFunctionInfo> 1814 i::Handle<i::SharedFunctionInfo>
1808 function_info(i::SharedFunctionInfo::cast(*obj), isolate); 1815 function_info(i::SharedFunctionInfo::cast(*obj), isolate);
1809 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( 1816 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo(
1810 function_info, isolate->global_context()); 1817 function_info, isolate->global_context());
1811 } else { 1818 } else {
1812 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); 1819 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate);
1813 } 1820 }
1814 EXCEPTION_PREAMBLE(isolate); 1821 EXCEPTION_PREAMBLE(isolate);
(...skipping 17 matching lines...) Expand all
1832 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1839 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1833 } else { 1840 } else {
1834 result = 1841 result =
1835 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()); 1842 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared());
1836 } 1843 }
1837 return result; 1844 return result;
1838 } 1845 }
1839 1846
1840 1847
1841 Local<Value> Script::Id() { 1848 Local<Value> Script::Id() {
1842 i::Isolate* isolate = i::Isolate::Current(); 1849 i::Handle<i::HeapObject> obj =
1850 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1851 i::Isolate* isolate = obj->GetIsolate();
1843 ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>()); 1852 ON_BAILOUT(isolate, "v8::Script::Id()", return Local<Value>());
1844 LOG_API(isolate, "Script::Id"); 1853 LOG_API(isolate, "Script::Id");
1845 i::Object* raw_id = NULL; 1854 i::Object* raw_id = NULL;
1846 { 1855 {
1847 i::HandleScope scope(isolate); 1856 i::HandleScope scope(isolate);
1848 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 1857 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1849 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 1858 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1850 i::Handle<i::Object> id(script->id(), isolate); 1859 i::Handle<i::Object> id(script->id(), isolate);
1851 raw_id = *id; 1860 raw_id = *id;
1852 } 1861 }
1853 i::Handle<i::Object> id(raw_id, isolate); 1862 i::Handle<i::Object> id(raw_id, isolate);
1854 return Utils::ToLocal(id); 1863 return Utils::ToLocal(id);
1855 } 1864 }
1856 1865
1857 1866
1858 int Script::GetId() { 1867 int Script::GetId() {
1859 i::Isolate* isolate = i::Isolate::Current(); 1868 i::Handle<i::HeapObject> obj =
1869 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1870 i::Isolate* isolate = obj->GetIsolate();
1860 ON_BAILOUT(isolate, "v8::Script::Id()", return -1); 1871 ON_BAILOUT(isolate, "v8::Script::Id()", return -1);
1861 LOG_API(isolate, "Script::Id"); 1872 LOG_API(isolate, "Script::Id");
1862 { 1873 {
1863 i::HandleScope scope(isolate); 1874 i::HandleScope scope(isolate);
1864 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 1875 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1865 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 1876 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1866 return script->id()->value(); 1877 return script->id()->value();
1867 } 1878 }
1868 } 1879 }
1869 1880
1870 1881
1871 int Script::GetLineNumber(int code_pos) { 1882 int Script::GetLineNumber(int code_pos) {
1872 i::Isolate* isolate = i::Isolate::Current(); 1883 i::Handle<i::HeapObject> obj =
1884 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1885 i::Isolate* isolate = obj->GetIsolate();
1873 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1); 1886 ON_BAILOUT(isolate, "v8::Script::GetLineNumber()", return -1);
1874 LOG_API(isolate, "Script::GetLineNumber"); 1887 LOG_API(isolate, "Script::GetLineNumber");
1875 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1876 if (obj->IsScript()) { 1888 if (obj->IsScript()) {
1877 i::Handle<i::Script> script = i::Handle<i::Script>(i::Script::cast(*obj)); 1889 i::Handle<i::Script> script = i::Handle<i::Script>(i::Script::cast(*obj));
1878 return i::GetScriptLineNumber(script, code_pos); 1890 return i::GetScriptLineNumber(script, code_pos);
1879 } else { 1891 } else {
1880 return -1; 1892 return -1;
1881 } 1893 }
1882 } 1894 }
1883 1895
1884 1896
1885 Handle<Value> Script::GetScriptName() { 1897 Handle<Value> Script::GetScriptName() {
1886 i::Isolate* isolate = i::Isolate::Current(); 1898 i::Handle<i::HeapObject> obj =
1899 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1900 i::Isolate* isolate = obj->GetIsolate();
1887 ON_BAILOUT(isolate, "v8::Script::GetName()", return Handle<String>()); 1901 ON_BAILOUT(isolate, "v8::Script::GetName()", return Handle<String>());
1888 LOG_API(isolate, "Script::GetName"); 1902 LOG_API(isolate, "Script::GetName");
1889 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1890 if (obj->IsScript()) { 1903 if (obj->IsScript()) {
1891 i::Object* name = i::Script::cast(*obj)->name(); 1904 i::Object* name = i::Script::cast(*obj)->name();
1892 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); 1905 return Utils::ToLocal(i::Handle<i::Object>(name, isolate));
1893 } else { 1906 } else {
1894 return Handle<String>(); 1907 return Handle<String>();
1895 } 1908 }
1896 } 1909 }
1897 1910
1898 1911
1899 void Script::SetData(v8::Handle<String> data) { 1912 void Script::SetData(v8::Handle<String> data) {
1900 i::Isolate* isolate = i::Isolate::Current(); 1913 i::Handle<i::HeapObject> obj =
1914 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this));
1915 i::Isolate* isolate = obj->GetIsolate();
1901 ON_BAILOUT(isolate, "v8::Script::SetData()", return); 1916 ON_BAILOUT(isolate, "v8::Script::SetData()", return);
1902 LOG_API(isolate, "Script::SetData"); 1917 LOG_API(isolate, "Script::SetData");
1903 { 1918 {
1904 i::HandleScope scope(isolate); 1919 i::HandleScope scope(isolate);
1905 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this); 1920 i::Handle<i::SharedFunctionInfo> function_info = OpenScript(this);
1906 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); 1921 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
1907 i::Handle<i::Script> script(i::Script::cast(function_info->script())); 1922 i::Handle<i::Script> script(i::Script::cast(function_info->script()));
1908 script->set_data(*raw_data); 1923 script->set_data(*raw_data);
1909 } 1924 }
1910 } 1925 }
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3944 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3930 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); 3945 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false);
3931 ENTER_V8(isolate); 3946 ENTER_V8(isolate);
3932 i::HandleScope scope(isolate); 3947 i::HandleScope scope(isolate);
3933 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 3948 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3934 if (obj->IsJSFunction()) return true; 3949 if (obj->IsJSFunction()) return true;
3935 return i::Execution::GetFunctionDelegate(isolate, obj)->IsJSFunction(); 3950 return i::Execution::GetFunctionDelegate(isolate, obj)->IsJSFunction();
3936 } 3951 }
3937 3952
3938 3953
3939 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, 3954 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv,
3940 int argc, 3955 int argc,
3941 v8::Handle<v8::Value> argv[]) { 3956 v8::Handle<v8::Value> argv[]) {
3942 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3957 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3943 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", 3958 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()",
3944 return Local<v8::Value>()); 3959 return Local<v8::Value>());
3945 LOG_API(isolate, "Object::CallAsFunction"); 3960 LOG_API(isolate, "Object::CallAsFunction");
3946 ENTER_V8(isolate); 3961 ENTER_V8(isolate);
3947 i::Logger::TimerEventScope timer_scope( 3962 i::Logger::TimerEventScope timer_scope(
3948 isolate, i::Logger::TimerEventScope::v8_execute); 3963 isolate, i::Logger::TimerEventScope::v8_execute);
3949 i::HandleScope scope(isolate); 3964 i::HandleScope scope(isolate);
3950 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); 3965 i::Handle<i::JSObject> obj = Utils::OpenHandle(this);
3951 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 3966 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
3952 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 3967 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
3953 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 3968 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
3954 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); 3969 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>();
3955 if (obj->IsJSFunction()) { 3970 if (obj->IsJSFunction()) {
3956 fun = i::Handle<i::JSFunction>::cast(obj); 3971 fun = i::Handle<i::JSFunction>::cast(obj);
3957 } else { 3972 } else {
3958 EXCEPTION_PREAMBLE(isolate); 3973 EXCEPTION_PREAMBLE(isolate);
3959 i::Handle<i::Object> delegate = i::Execution::TryGetFunctionDelegate( 3974 i::Handle<i::Object> delegate = i::Execution::TryGetFunctionDelegate(
3960 isolate, obj, &has_pending_exception); 3975 isolate, obj, &has_pending_exception);
3961 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 3976 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
3962 fun = i::Handle<i::JSFunction>::cast(delegate); 3977 fun = i::Handle<i::JSFunction>::cast(delegate);
3963 recv_obj = obj; 3978 recv_obj = obj;
3964 } 3979 }
3965 EXCEPTION_PREAMBLE(isolate); 3980 EXCEPTION_PREAMBLE(isolate);
3966 i::Handle<i::Object> returned = i::Execution::Call( 3981 i::Handle<i::Object> returned = i::Execution::Call(
3967 isolate, fun, recv_obj, argc, args, &has_pending_exception); 3982 isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
3968 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); 3983 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>());
3969 return Utils::ToLocal(scope.CloseAndEscape(returned)); 3984 return Utils::ToLocal(scope.CloseAndEscape(returned));
3970 } 3985 }
3971 3986
3972 3987
3973 Local<v8::Value> Object::CallAsConstructor(int argc, 3988 Local<v8::Value> Object::CallAsConstructor(int argc,
3974 v8::Handle<v8::Value> argv[]) { 3989 v8::Handle<v8::Value> argv[]) {
3975 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3990 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3976 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", 3991 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()",
3977 return Local<v8::Object>()); 3992 return Local<v8::Object>());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4041 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 4056 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4042 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4057 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4043 EXCEPTION_PREAMBLE(isolate); 4058 EXCEPTION_PREAMBLE(isolate);
4044 i::Handle<i::Object> returned = 4059 i::Handle<i::Object> returned =
4045 i::Execution::New(function, argc, args, &has_pending_exception); 4060 i::Execution::New(function, argc, args, &has_pending_exception);
4046 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); 4061 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>());
4047 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); 4062 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned)));
4048 } 4063 }
4049 4064
4050 4065
4051 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, 4066 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc,
4052 v8::Handle<v8::Value> argv[]) { 4067 v8::Handle<v8::Value> argv[]) {
4053 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4068 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4054 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); 4069 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>());
4055 LOG_API(isolate, "Function::Call"); 4070 LOG_API(isolate, "Function::Call");
4056 ENTER_V8(isolate); 4071 ENTER_V8(isolate);
4057 i::Logger::TimerEventScope timer_scope( 4072 i::Logger::TimerEventScope timer_scope(
4058 isolate, i::Logger::TimerEventScope::v8_execute); 4073 isolate, i::Logger::TimerEventScope::v8_execute);
4059 i::Object* raw_result = NULL; 4074 i::Object* raw_result = NULL;
4060 { 4075 {
4061 i::HandleScope scope(isolate); 4076 i::HandleScope scope(isolate);
4062 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); 4077 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this);
4063 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); 4078 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
4064 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); 4079 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
4065 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); 4080 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
4066 EXCEPTION_PREAMBLE(isolate); 4081 EXCEPTION_PREAMBLE(isolate);
4067 i::Handle<i::Object> returned = i::Execution::Call( 4082 i::Handle<i::Object> returned = i::Execution::Call(
4068 isolate, fun, recv_obj, argc, args, &has_pending_exception); 4083 isolate, fun, recv_obj, argc, args, &has_pending_exception, true);
4069 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>()); 4084 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>());
4070 raw_result = *returned; 4085 raw_result = *returned;
4071 } 4086 }
4072 i::Handle<i::Object> result(raw_result, isolate); 4087 i::Handle<i::Object> result(raw_result, isolate);
4073 return Utils::ToLocal(result); 4088 return Utils::ToLocal(result);
4074 } 4089 }
4075 4090
4076 4091
4077 void Function::SetName(v8::Handle<v8::String> name) { 4092 void Function::SetName(v8::Handle<v8::String> name) {
4078 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 4093 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 } 4717 }
4703 } 4718 }
4704 // Recursive slow path can potentially be unreasonable slow. Flatten. 4719 // Recursive slow path can potentially be unreasonable slow. Flatten.
4705 str = FlattenGetString(str); 4720 str = FlattenGetString(str);
4706 Utf8WriterVisitor writer(buffer, capacity, false); 4721 Utf8WriterVisitor writer(buffer, capacity, false);
4707 i::String::VisitFlat(&writer, *str); 4722 i::String::VisitFlat(&writer, *str);
4708 return writer.CompleteWrite(write_null, nchars_ref); 4723 return writer.CompleteWrite(write_null, nchars_ref);
4709 } 4724 }
4710 4725
4711 4726
4712 int String::WriteAscii(char* buffer,
4713 int start,
4714 int length,
4715 int options) const {
4716 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
4717 LOG_API(isolate, "String::WriteAscii");
4718 ENTER_V8(isolate);
4719 ASSERT(start >= 0 && length >= -1);
4720 i::Handle<i::String> str = Utils::OpenHandle(this);
4721 isolate->string_tracker()->RecordWrite(str);
4722 if (options & HINT_MANY_WRITES_EXPECTED) {
4723 FlattenString(str); // Flatten the string for efficiency.
4724 }
4725
4726 int end = length;
4727 if ((length == -1) || (length > str->length() - start)) {
4728 end = str->length() - start;
4729 }
4730 if (end < 0) return 0;
4731 i::StringCharacterStream write_stream(*str, isolate->write_iterator(), start);
4732 int i;
4733 for (i = 0; i < end; i++) {
4734 char c = static_cast<char>(write_stream.GetNext());
4735 if (c == '\0' && !(options & PRESERVE_ASCII_NULL)) c = ' ';
4736 buffer[i] = c;
4737 }
4738 if (!(options & NO_NULL_TERMINATION) && (length == -1 || i < length)) {
4739 buffer[i] = '\0';
4740 }
4741 return i;
4742 }
4743
4744
4745 template<typename CharType> 4727 template<typename CharType>
4746 static inline int WriteHelper(const String* string, 4728 static inline int WriteHelper(const String* string,
4747 CharType* buffer, 4729 CharType* buffer,
4748 int start, 4730 int start,
4749 int length, 4731 int length,
4750 int options) { 4732 int options) {
4751 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); 4733 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate();
4752 LOG_API(isolate, "String::Write"); 4734 LOG_API(isolate, "String::Write");
4753 ENTER_V8(isolate); 4735 ENTER_V8(isolate);
4754 ASSERT(start >= 0 && length >= -1); 4736 ASSERT(start >= 0 && length >= -1);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 i::RandomNumberGenerator::SetEntropySource(entropy_source); 4958 i::RandomNumberGenerator::SetEntropySource(entropy_source);
4977 } 4959 }
4978 4960
4979 4961
4980 void v8::V8::SetReturnAddressLocationResolver( 4962 void v8::V8::SetReturnAddressLocationResolver(
4981 ReturnAddressLocationResolver return_address_resolver) { 4963 ReturnAddressLocationResolver return_address_resolver) {
4982 i::V8::SetReturnAddressLocationResolver(return_address_resolver); 4964 i::V8::SetReturnAddressLocationResolver(return_address_resolver);
4983 } 4965 }
4984 4966
4985 4967
4986 bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) {
4987 return SetFunctionEntryHook(Isolate::GetCurrent(), entry_hook);
4988 }
4989
4990
4991 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate, 4968 bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate,
4992 FunctionEntryHook entry_hook) { 4969 FunctionEntryHook entry_hook) {
4993 ASSERT(ext_isolate != NULL); 4970 ASSERT(ext_isolate != NULL);
4994 ASSERT(entry_hook != NULL); 4971 ASSERT(entry_hook != NULL);
4995 4972
4996 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate); 4973 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate);
4997 4974
4998 // The entry hook can only be set before the Isolate is initialized, as 4975 // The entry hook can only be set before the Isolate is initialized, as
4999 // otherwise the Isolate's code stubs generated at initialization won't 4976 // otherwise the Isolate's code stubs generated at initialization won't
5000 // contain entry hooks. 4977 // contain entry hooks.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5041 } 5018 }
5042 5019
5043 5020
5044 HeapStatistics::HeapStatistics(): total_heap_size_(0), 5021 HeapStatistics::HeapStatistics(): total_heap_size_(0),
5045 total_heap_size_executable_(0), 5022 total_heap_size_executable_(0),
5046 total_physical_size_(0), 5023 total_physical_size_(0),
5047 used_heap_size_(0), 5024 used_heap_size_(0),
5048 heap_size_limit_(0) { } 5025 heap_size_limit_(0) { }
5049 5026
5050 5027
5051 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) {
5052 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5053 if (isolate == NULL || !isolate->IsInitialized()) {
5054 // Isolate is unitialized thus heap is not configured yet.
5055 heap_statistics->total_heap_size_ = 0;
5056 heap_statistics->total_heap_size_executable_ = 0;
5057 heap_statistics->total_physical_size_ = 0;
5058 heap_statistics->used_heap_size_ = 0;
5059 heap_statistics->heap_size_limit_ = 0;
5060 return;
5061 }
5062 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate);
5063 return ext_isolate->GetHeapStatistics(heap_statistics);
5064 }
5065
5066
5067 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { 5028 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) {
5068 i::Isolate* isolate = i::Isolate::Current(); 5029 i::Isolate* isolate = i::Isolate::Current();
5069 isolate->heap()->VisitExternalResources(visitor); 5030 isolate->heap()->VisitExternalResources(visitor);
5070 } 5031 }
5071 5032
5072 5033
5073 class VisitorAdapter : public i::ObjectVisitor { 5034 class VisitorAdapter : public i::ObjectVisitor {
5074 public: 5035 public:
5075 explicit VisitorAdapter(PersistentHandleVisitor* visitor) 5036 explicit VisitorAdapter(PersistentHandleVisitor* visitor)
5076 : visitor_(visitor) {} 5037 : visitor_(visitor) {}
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
5657 isolate->heap()->external_string_table()->AddString(*external); 5618 isolate->heap()->external_string_table()->AddString(*external);
5658 } 5619 }
5659 return result; 5620 return result;
5660 } 5621 }
5661 5622
5662 5623
5663 bool v8::String::CanMakeExternal() { 5624 bool v8::String::CanMakeExternal() {
5664 if (!internal::FLAG_clever_optimizations) return false; 5625 if (!internal::FLAG_clever_optimizations) return false;
5665 i::Handle<i::String> obj = Utils::OpenHandle(this); 5626 i::Handle<i::String> obj = Utils::OpenHandle(this);
5666 i::Isolate* isolate = obj->GetIsolate(); 5627 i::Isolate* isolate = obj->GetIsolate();
5628
5629 // TODO(yangguo): Externalizing sliced/cons strings allocates.
5630 // This rule can be removed when all code that can
5631 // trigger an access check is handlified and therefore GC safe.
5632 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false;
5633
5667 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; 5634 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
5668 int size = obj->Size(); // Byte size of the original string. 5635 int size = obj->Size(); // Byte size of the original string.
5669 if (size < i::ExternalString::kShortSize) return false; 5636 if (size < i::ExternalString::kShortSize) return false;
5670 i::StringShape shape(*obj); 5637 i::StringShape shape(*obj);
5671 return !shape.IsExternal(); 5638 return !shape.IsExternal();
5672 } 5639 }
5673 5640
5674 5641
5675 Local<v8::Object> v8::Object::New() { 5642 Local<v8::Object> v8::Object::New() {
5676 i::Isolate* isolate = i::Isolate::Current(); 5643 i::Isolate* isolate = i::Isolate::Current();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
6015 return static_cast<size_t>(obj->byte_offset()->Number()); 5982 return static_cast<size_t>(obj->byte_offset()->Number());
6016 } 5983 }
6017 5984
6018 5985
6019 size_t v8::ArrayBufferView::ByteLength() { 5986 size_t v8::ArrayBufferView::ByteLength() {
6020 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); 5987 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6021 return static_cast<size_t>(obj->byte_length()->Number()); 5988 return static_cast<size_t>(obj->byte_length()->Number());
6022 } 5989 }
6023 5990
6024 5991
6025 void* v8::ArrayBufferView::BaseAddress() {
6026 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this);
6027 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer()));
6028 void* buffer_data = buffer->backing_store();
6029 size_t byte_offset = static_cast<size_t>(obj->byte_offset()->Number());
6030 return static_cast<uint8_t*>(buffer_data) + byte_offset;
6031 }
6032
6033
6034 size_t v8::TypedArray::Length() { 5992 size_t v8::TypedArray::Length() {
6035 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); 5993 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this);
6036 return static_cast<size_t>(obj->length()->Number()); 5994 return static_cast<size_t>(obj->length()->Number());
6037 } 5995 }
6038 5996
6039 5997
6040 static inline void SetupArrayBufferView( 5998 static inline void SetupArrayBufferView(
6041 i::Isolate* isolate, 5999 i::Isolate* isolate,
6042 i::Handle<i::JSArrayBufferView> obj, 6000 i::Handle<i::JSArrayBufferView> obj,
6043 i::Handle<i::JSArrayBuffer> buffer, 6001 i::Handle<i::JSArrayBuffer> buffer,
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
6969 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); 6927 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
6970 } 6928 }
6971 6929
6972 6930
6973 const char* CpuProfileNode::GetBailoutReason() const { 6931 const char* CpuProfileNode::GetBailoutReason() const {
6974 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6932 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
6975 return node->entry()->bailout_reason(); 6933 return node->entry()->bailout_reason();
6976 } 6934 }
6977 6935
6978 6936
6979 double CpuProfileNode::GetSelfSamplesCount() const {
6980 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
6981 }
6982
6983
6984 unsigned CpuProfileNode::GetHitCount() const { 6937 unsigned CpuProfileNode::GetHitCount() const {
6985 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 6938 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
6986 } 6939 }
6987 6940
6988 6941
6989 unsigned CpuProfileNode::GetCallUid() const { 6942 unsigned CpuProfileNode::GetCallUid() const {
6990 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); 6943 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
6991 } 6944 }
6992 6945
6993 6946
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
7527 void HandleScopeImplementer::BeginDeferredScope() { 7480 void HandleScopeImplementer::BeginDeferredScope() {
7528 ASSERT(last_handle_before_deferred_block_ == NULL); 7481 ASSERT(last_handle_before_deferred_block_ == NULL);
7529 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next; 7482 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
7530 } 7483 }
7531 7484
7532 7485
7533 DeferredHandles::~DeferredHandles() { 7486 DeferredHandles::~DeferredHandles() {
7534 isolate_->UnlinkDeferredHandles(this); 7487 isolate_->UnlinkDeferredHandles(this);
7535 7488
7536 for (int i = 0; i < blocks_.length(); i++) { 7489 for (int i = 0; i < blocks_.length(); i++) {
7537 #ifdef ENABLE_EXTRA_CHECKS 7490 #ifdef ENABLE_HANDLE_ZAPPING
7538 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]); 7491 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
7539 #endif 7492 #endif
7540 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]); 7493 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
7541 } 7494 }
7542 } 7495 }
7543 7496
7544 7497
7545 void DeferredHandles::Iterate(ObjectVisitor* v) { 7498 void DeferredHandles::Iterate(ObjectVisitor* v) {
7546 ASSERT(!blocks_.is_empty()); 7499 ASSERT(!blocks_.is_empty());
7547 7500
(...skipping 27 matching lines...) Expand all
7575 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7528 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7576 Address callback_address = 7529 Address callback_address =
7577 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7530 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7578 VMState<EXTERNAL> state(isolate); 7531 VMState<EXTERNAL> state(isolate);
7579 ExternalCallbackScope call_scope(isolate, callback_address); 7532 ExternalCallbackScope call_scope(isolate, callback_address);
7580 callback(info); 7533 callback(info);
7581 } 7534 }
7582 7535
7583 7536
7584 } } // namespace v8::internal 7537 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/arguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698