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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "src/startup-data-util.h" | 61 #include "src/startup-data-util.h" |
62 #include "src/tracing/trace-event.h" | 62 #include "src/tracing/trace-event.h" |
63 #include "src/unicode-inl.h" | 63 #include "src/unicode-inl.h" |
64 #include "src/v8.h" | 64 #include "src/v8.h" |
65 #include "src/v8threads.h" | 65 #include "src/v8threads.h" |
66 #include "src/version.h" | 66 #include "src/version.h" |
67 #include "src/vm-state-inl.h" | 67 #include "src/vm-state-inl.h" |
68 | 68 |
69 namespace v8 { | 69 namespace v8 { |
70 | 70 |
71 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) | 71 #define LOG_API(isolate, class_name, function_name) \ |
72 | 72 i::RuntimeCallTimerScope _runtime_timer( \ |
| 73 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \ |
| 74 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name)) |
73 | 75 |
74 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) | 76 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) |
75 | 77 |
76 | 78 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, \ |
77 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 79 function_name, bailout_value, \ |
78 bailout_value, HandleScopeClass, \ | 80 HandleScopeClass, do_callback) \ |
79 do_callback) \ | 81 if (IsExecutionTerminatingCheck(isolate)) { \ |
80 if (IsExecutionTerminatingCheck(isolate)) { \ | 82 return bailout_value; \ |
81 return bailout_value; \ | 83 } \ |
82 } \ | 84 HandleScopeClass handle_scope(isolate); \ |
83 HandleScopeClass handle_scope(isolate); \ | 85 CallDepthScope call_depth_scope(isolate, context, do_callback); \ |
84 CallDepthScope call_depth_scope(isolate, context, do_callback); \ | 86 LOG_API(isolate, class_name, function_name); \ |
85 LOG_API(isolate, function_name); \ | 87 ENTER_V8(isolate); \ |
86 ENTER_V8(isolate); \ | |
87 bool has_pending_exception = false | 88 bool has_pending_exception = false |
88 | 89 |
89 | 90 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ |
90 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT( \ | 91 bailout_value, HandleScopeClass, \ |
91 context, function_name, bailout_value, HandleScopeClass, do_callback) \ | 92 do_callback) \ |
92 auto isolate = context.IsEmpty() \ | 93 auto isolate = context.IsEmpty() \ |
93 ? i::Isolate::Current() \ | 94 ? i::Isolate::Current() \ |
94 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ | 95 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ |
95 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 96 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, class_name, function_name, \ |
96 bailout_value, HandleScopeClass, do_callback); | 97 bailout_value, HandleScopeClass, do_callback); |
97 | 98 |
| 99 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, class_name, function_name, \ |
| 100 T) \ |
| 101 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), class_name, \ |
| 102 function_name, MaybeLocal<T>(), \ |
| 103 InternalEscapableScope, false); |
98 | 104 |
99 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, function_name, T) \ | 105 #define PREPARE_FOR_EXECUTION(context, class_name, function_name, T) \ |
100 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), function_name, \ | 106 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ |
101 MaybeLocal<T>(), InternalEscapableScope, \ | 107 MaybeLocal<T>(), InternalEscapableScope, \ |
102 false); | 108 false) |
103 | 109 |
| 110 #define PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, class_name, \ |
| 111 function_name, T) \ |
| 112 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ |
| 113 MaybeLocal<T>(), InternalEscapableScope, \ |
| 114 true) |
104 | 115 |
105 #define PREPARE_FOR_EXECUTION(context, function_name, T) \ | 116 #define PREPARE_FOR_EXECUTION_PRIMITIVE(context, class_name, function_name, T) \ |
106 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, function_name, MaybeLocal<T>(), \ | 117 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, class_name, function_name, \ |
107 InternalEscapableScope, false) | 118 Nothing<T>(), i::HandleScope, false) |
108 | |
109 | |
110 #define PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, function_name, T) \ | |
111 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, function_name, MaybeLocal<T>(), \ | |
112 InternalEscapableScope, true) | |
113 | |
114 | |
115 #define PREPARE_FOR_EXECUTION_PRIMITIVE(context, function_name, T) \ | |
116 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, function_name, Nothing<T>(), \ | |
117 i::HandleScope, false) | |
118 | |
119 | 119 |
120 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ | 120 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ |
121 do { \ | 121 do { \ |
122 if (has_pending_exception) { \ | 122 if (has_pending_exception) { \ |
123 call_depth_scope.Escape(); \ | 123 call_depth_scope.Escape(); \ |
124 return value; \ | 124 return value; \ |
125 } \ | 125 } \ |
126 } while (false) | 126 } while (false) |
127 | 127 |
128 | 128 |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 max_executable_size, code_range_size); | 650 max_executable_size, code_range_size); |
651 } | 651 } |
652 if (constraints.stack_limit() != NULL) { | 652 if (constraints.stack_limit() != NULL) { |
653 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 653 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
654 isolate->stack_guard()->SetStackLimit(limit); | 654 isolate->stack_guard()->SetStackLimit(limit); |
655 } | 655 } |
656 } | 656 } |
657 | 657 |
658 | 658 |
659 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 659 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
660 LOG_API(isolate, "Persistent::New"); | 660 LOG_API(isolate, Persistent, New); |
661 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 661 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
662 #ifdef VERIFY_HEAP | 662 #ifdef VERIFY_HEAP |
663 if (i::FLAG_verify_heap) { | 663 if (i::FLAG_verify_heap) { |
664 (*obj)->ObjectVerify(); | 664 (*obj)->ObjectVerify(); |
665 } | 665 } |
666 #endif // VERIFY_HEAP | 666 #endif // VERIFY_HEAP |
667 return result.location(); | 667 return result.location(); |
668 } | 668 } |
669 | 669 |
670 | 670 |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1134 |
1135 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, | 1135 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, |
1136 FunctionCallback callback, | 1136 FunctionCallback callback, |
1137 v8::Local<Value> data, | 1137 v8::Local<Value> data, |
1138 v8::Local<Signature> signature, | 1138 v8::Local<Signature> signature, |
1139 int length) { | 1139 int length) { |
1140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1141 // Changes to the environment cannot be captured in the snapshot. Expect no | 1141 // Changes to the environment cannot be captured in the snapshot. Expect no |
1142 // function templates when the isolate is created for serialization. | 1142 // function templates when the isolate is created for serialization. |
1143 DCHECK(!i_isolate->serializer_enabled()); | 1143 DCHECK(!i_isolate->serializer_enabled()); |
1144 LOG_API(i_isolate, "FunctionTemplate::New"); | 1144 LOG_API(i_isolate, FunctionTemplate, New); |
1145 ENTER_V8(i_isolate); | 1145 ENTER_V8(i_isolate); |
1146 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, | 1146 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, |
1147 length, false); | 1147 length, false); |
1148 } | 1148 } |
1149 | 1149 |
1150 | 1150 |
1151 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( | 1151 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( |
1152 Isolate* isolate, FunctionCallback callback, | 1152 Isolate* isolate, FunctionCallback callback, |
1153 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, | 1153 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, |
1154 v8::Local<Signature> signature, int length) { | 1154 v8::Local<Signature> signature, int length) { |
1155 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1155 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1156 DCHECK(!i_isolate->serializer_enabled()); | 1156 DCHECK(!i_isolate->serializer_enabled()); |
1157 LOG_API(i_isolate, "FunctionTemplate::NewWithFastHandler"); | 1157 LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); |
1158 ENTER_V8(i_isolate); | 1158 ENTER_V8(i_isolate); |
1159 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, | 1159 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, |
1160 length, false); | 1160 length, false); |
1161 } | 1161 } |
1162 | 1162 |
1163 | 1163 |
1164 Local<Signature> Signature::New(Isolate* isolate, | 1164 Local<Signature> Signature::New(Isolate* isolate, |
1165 Local<FunctionTemplate> receiver) { | 1165 Local<FunctionTemplate> receiver) { |
1166 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); | 1166 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); |
1167 } | 1167 } |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 Local<ObjectTemplate> ObjectTemplate::New() { | 1331 Local<ObjectTemplate> ObjectTemplate::New() { |
1332 return New(i::Isolate::Current(), Local<FunctionTemplate>()); | 1332 return New(i::Isolate::Current(), Local<FunctionTemplate>()); |
1333 } | 1333 } |
1334 | 1334 |
1335 static Local<ObjectTemplate> ObjectTemplateNew( | 1335 static Local<ObjectTemplate> ObjectTemplateNew( |
1336 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, | 1336 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, |
1337 bool do_not_cache) { | 1337 bool do_not_cache) { |
1338 // Changes to the environment cannot be captured in the snapshot. Expect no | 1338 // Changes to the environment cannot be captured in the snapshot. Expect no |
1339 // object templates when the isolate is created for serialization. | 1339 // object templates when the isolate is created for serialization. |
1340 DCHECK(!isolate->serializer_enabled()); | 1340 DCHECK(!isolate->serializer_enabled()); |
1341 LOG_API(isolate, "ObjectTemplate::New"); | 1341 LOG_API(isolate, ObjectTemplate, New); |
1342 ENTER_V8(isolate); | 1342 ENTER_V8(isolate); |
1343 i::Handle<i::Struct> struct_obj = | 1343 i::Handle<i::Struct> struct_obj = |
1344 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1344 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
1345 i::Handle<i::ObjectTemplateInfo> obj = | 1345 i::Handle<i::ObjectTemplateInfo> obj = |
1346 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1346 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1347 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1347 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1348 int next_serial_number = 0; | 1348 int next_serial_number = 0; |
1349 if (!do_not_cache) { | 1349 if (!do_not_cache) { |
1350 next_serial_number = isolate->next_serial_number() + 1; | 1350 next_serial_number = isolate->next_serial_number() + 1; |
1351 isolate->set_next_serial_number(next_serial_number); | 1351 isolate->set_next_serial_number(next_serial_number); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( | 1709 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( |
1710 function_info, isolate->native_context()); | 1710 function_info, isolate->native_context()); |
1711 return ToApiHandle<Script>(function); | 1711 return ToApiHandle<Script>(function); |
1712 } | 1712 } |
1713 | 1713 |
1714 | 1714 |
1715 int UnboundScript::GetId() { | 1715 int UnboundScript::GetId() { |
1716 i::Handle<i::HeapObject> obj = | 1716 i::Handle<i::HeapObject> obj = |
1717 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1717 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
1718 i::Isolate* isolate = obj->GetIsolate(); | 1718 i::Isolate* isolate = obj->GetIsolate(); |
1719 LOG_API(isolate, "v8::UnboundScript::GetId"); | 1719 LOG_API(isolate, UnboundScript, GetId); |
1720 i::HandleScope scope(isolate); | 1720 i::HandleScope scope(isolate); |
1721 i::Handle<i::SharedFunctionInfo> function_info( | 1721 i::Handle<i::SharedFunctionInfo> function_info( |
1722 i::SharedFunctionInfo::cast(*obj)); | 1722 i::SharedFunctionInfo::cast(*obj)); |
1723 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1723 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
1724 return script->id(); | 1724 return script->id(); |
1725 } | 1725 } |
1726 | 1726 |
1727 | 1727 |
1728 int UnboundScript::GetLineNumber(int code_pos) { | 1728 int UnboundScript::GetLineNumber(int code_pos) { |
1729 i::Handle<i::SharedFunctionInfo> obj = | 1729 i::Handle<i::SharedFunctionInfo> obj = |
1730 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1730 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1731 i::Isolate* isolate = obj->GetIsolate(); | 1731 i::Isolate* isolate = obj->GetIsolate(); |
1732 LOG_API(isolate, "UnboundScript::GetLineNumber"); | 1732 LOG_API(isolate, UnboundScript, GetLineNumber); |
1733 if (obj->script()->IsScript()) { | 1733 if (obj->script()->IsScript()) { |
1734 i::Handle<i::Script> script(i::Script::cast(obj->script())); | 1734 i::Handle<i::Script> script(i::Script::cast(obj->script())); |
1735 return i::Script::GetLineNumber(script, code_pos); | 1735 return i::Script::GetLineNumber(script, code_pos); |
1736 } else { | 1736 } else { |
1737 return -1; | 1737 return -1; |
1738 } | 1738 } |
1739 } | 1739 } |
1740 | 1740 |
1741 | 1741 |
1742 Local<Value> UnboundScript::GetScriptName() { | 1742 Local<Value> UnboundScript::GetScriptName() { |
1743 i::Handle<i::SharedFunctionInfo> obj = | 1743 i::Handle<i::SharedFunctionInfo> obj = |
1744 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1744 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1745 i::Isolate* isolate = obj->GetIsolate(); | 1745 i::Isolate* isolate = obj->GetIsolate(); |
1746 LOG_API(isolate, "UnboundScript::GetName"); | 1746 LOG_API(isolate, UnboundScript, GetName); |
1747 if (obj->script()->IsScript()) { | 1747 if (obj->script()->IsScript()) { |
1748 i::Object* name = i::Script::cast(obj->script())->name(); | 1748 i::Object* name = i::Script::cast(obj->script())->name(); |
1749 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); | 1749 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); |
1750 } else { | 1750 } else { |
1751 return Local<String>(); | 1751 return Local<String>(); |
1752 } | 1752 } |
1753 } | 1753 } |
1754 | 1754 |
1755 | 1755 |
1756 Local<Value> UnboundScript::GetSourceURL() { | 1756 Local<Value> UnboundScript::GetSourceURL() { |
1757 i::Handle<i::SharedFunctionInfo> obj = | 1757 i::Handle<i::SharedFunctionInfo> obj = |
1758 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1758 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1759 i::Isolate* isolate = obj->GetIsolate(); | 1759 i::Isolate* isolate = obj->GetIsolate(); |
1760 LOG_API(isolate, "UnboundScript::GetSourceURL"); | 1760 LOG_API(isolate, UnboundScript, GetSourceURL); |
1761 if (obj->script()->IsScript()) { | 1761 if (obj->script()->IsScript()) { |
1762 i::Object* url = i::Script::cast(obj->script())->source_url(); | 1762 i::Object* url = i::Script::cast(obj->script())->source_url(); |
1763 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1763 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
1764 } else { | 1764 } else { |
1765 return Local<String>(); | 1765 return Local<String>(); |
1766 } | 1766 } |
1767 } | 1767 } |
1768 | 1768 |
1769 | 1769 |
1770 Local<Value> UnboundScript::GetSourceMappingURL() { | 1770 Local<Value> UnboundScript::GetSourceMappingURL() { |
1771 i::Handle<i::SharedFunctionInfo> obj = | 1771 i::Handle<i::SharedFunctionInfo> obj = |
1772 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1772 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1773 i::Isolate* isolate = obj->GetIsolate(); | 1773 i::Isolate* isolate = obj->GetIsolate(); |
1774 LOG_API(isolate, "UnboundScript::GetSourceMappingURL"); | 1774 LOG_API(isolate, UnboundScript, GetSourceMappingURL); |
1775 if (obj->script()->IsScript()) { | 1775 if (obj->script()->IsScript()) { |
1776 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); | 1776 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); |
1777 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1777 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
1778 } else { | 1778 } else { |
1779 return Local<String>(); | 1779 return Local<String>(); |
1780 } | 1780 } |
1781 } | 1781 } |
1782 | 1782 |
1783 | 1783 |
1784 MaybeLocal<Value> Script::Run(Local<Context> context) { | 1784 MaybeLocal<Value> Script::Run(Local<Context> context) { |
1785 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) | 1785 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Script, Run, Value) |
1786 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 1786 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
1787 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1787 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
1788 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 1788 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
1789 TRACE_EVENT0("v8", "V8.Execute"); | 1789 TRACE_EVENT0("v8", "V8.Execute"); |
1790 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); | 1790 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); |
1791 i::Handle<i::Object> receiver = isolate->global_proxy(); | 1791 i::Handle<i::Object> receiver = isolate->global_proxy(); |
1792 Local<Value> result; | 1792 Local<Value> result; |
1793 has_pending_exception = | 1793 has_pending_exception = |
1794 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), | 1794 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), |
1795 &result); | 1795 &result); |
(...skipping 16 matching lines...) Expand all Loading... |
1812 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1812 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1813 return ToApiHandle<UnboundScript>( | 1813 return ToApiHandle<UnboundScript>( |
1814 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); | 1814 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
1815 } | 1815 } |
1816 | 1816 |
1817 | 1817 |
1818 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( | 1818 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( |
1819 Isolate* v8_isolate, Source* source, CompileOptions options, | 1819 Isolate* v8_isolate, Source* source, CompileOptions options, |
1820 bool is_module) { | 1820 bool is_module) { |
1821 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1821 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
1822 PREPARE_FOR_EXECUTION_WITH_ISOLATE( | 1822 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, |
1823 isolate, "v8::ScriptCompiler::CompileUnbound()", UnboundScript); | 1823 UnboundScript); |
1824 | 1824 |
1825 // Don't try to produce any kind of cache when the debugger is loaded. | 1825 // Don't try to produce any kind of cache when the debugger is loaded. |
1826 if (isolate->debug()->is_loaded() && | 1826 if (isolate->debug()->is_loaded() && |
1827 (options == kProduceParserCache || options == kProduceCodeCache)) { | 1827 (options == kProduceParserCache || options == kProduceCodeCache)) { |
1828 options = kNoCompileOptions; | 1828 options = kNoCompileOptions; |
1829 } | 1829 } |
1830 | 1830 |
1831 i::ScriptData* script_data = NULL; | 1831 i::ScriptData* script_data = NULL; |
1832 if (options == kConsumeParserCache || options == kConsumeCodeCache) { | 1832 if (options == kConsumeParserCache || options == kConsumeCodeCache) { |
1833 DCHECK(source->cached_data); | 1833 DCHECK(source->cached_data); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 bool first_char_; | 1972 bool first_char_; |
1973 i::UnicodeCache unicode_cache_; | 1973 i::UnicodeCache unicode_cache_; |
1974 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); | 1974 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); |
1975 }; | 1975 }; |
1976 | 1976 |
1977 | 1977 |
1978 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( | 1978 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
1979 Local<Context> v8_context, Source* source, size_t arguments_count, | 1979 Local<Context> v8_context, Source* source, size_t arguments_count, |
1980 Local<String> arguments[], size_t context_extension_count, | 1980 Local<String> arguments[], size_t context_extension_count, |
1981 Local<Object> context_extensions[]) { | 1981 Local<Object> context_extensions[]) { |
1982 PREPARE_FOR_EXECUTION( | 1982 PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunctionInContext, |
1983 v8_context, "v8::ScriptCompiler::CompileFunctionInContext()", Function); | 1983 Function); |
1984 i::Handle<i::String> source_string; | 1984 i::Handle<i::String> source_string; |
1985 auto factory = isolate->factory(); | 1985 auto factory = isolate->factory(); |
1986 if (arguments_count) { | 1986 if (arguments_count) { |
1987 source_string = factory->NewStringFromStaticChars("(function("); | 1987 source_string = factory->NewStringFromStaticChars("(function("); |
1988 for (size_t i = 0; i < arguments_count; ++i) { | 1988 for (size_t i = 0; i < arguments_count; ++i) { |
1989 IsIdentifierHelper helper; | 1989 IsIdentifierHelper helper; |
1990 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { | 1990 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { |
1991 return Local<Function>(); | 1991 return Local<Function>(); |
1992 } | 1992 } |
1993 has_pending_exception = | 1993 has_pending_exception = |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2087 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
2088 return new i::BackgroundParsingTask(source->impl(), options, | 2088 return new i::BackgroundParsingTask(source->impl(), options, |
2089 i::FLAG_stack_size, isolate); | 2089 i::FLAG_stack_size, isolate); |
2090 } | 2090 } |
2091 | 2091 |
2092 | 2092 |
2093 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, | 2093 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, |
2094 StreamedSource* v8_source, | 2094 StreamedSource* v8_source, |
2095 Local<String> full_source_string, | 2095 Local<String> full_source_string, |
2096 const ScriptOrigin& origin) { | 2096 const ScriptOrigin& origin) { |
2097 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); | 2097 PREPARE_FOR_EXECUTION(context, ScriptCompiler, Compile, Script); |
2098 i::StreamedSource* source = v8_source->impl(); | 2098 i::StreamedSource* source = v8_source->impl(); |
2099 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); | 2099 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); |
2100 i::Handle<i::Script> script = isolate->factory()->NewScript(str); | 2100 i::Handle<i::Script> script = isolate->factory()->NewScript(str); |
2101 if (!origin.ResourceName().IsEmpty()) { | 2101 if (!origin.ResourceName().IsEmpty()) { |
2102 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 2102 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
2103 } | 2103 } |
2104 if (!origin.ResourceLineOffset().IsEmpty()) { | 2104 if (!origin.ResourceLineOffset().IsEmpty()) { |
2105 script->set_line_offset( | 2105 script->set_line_offset( |
2106 static_cast<int>(origin.ResourceLineOffset()->Value())); | 2106 static_cast<int>(origin.ResourceLineOffset()->Value())); |
2107 } | 2107 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 } else { | 2286 } else { |
2287 return v8::Local<Value>(); | 2287 return v8::Local<Value>(); |
2288 } | 2288 } |
2289 } | 2289 } |
2290 | 2290 |
2291 | 2291 |
2292 MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const { | 2292 MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const { |
2293 if (!HasCaught()) return v8::Local<Value>(); | 2293 if (!HasCaught()) return v8::Local<Value>(); |
2294 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 2294 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
2295 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 2295 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
2296 PREPARE_FOR_EXECUTION(context, "v8::TryCatch::StackTrace", Value); | 2296 PREPARE_FOR_EXECUTION(context, TryCatch, StackTrace, Value); |
2297 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 2297 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
2298 i::Handle<i::String> name = isolate->factory()->stack_string(); | 2298 i::Handle<i::String> name = isolate->factory()->stack_string(); |
2299 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); | 2299 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); |
2300 has_pending_exception = !maybe.IsJust(); | 2300 has_pending_exception = !maybe.IsJust(); |
2301 RETURN_ON_FAILED_EXECUTION(Value); | 2301 RETURN_ON_FAILED_EXECUTION(Value); |
2302 if (!maybe.FromJust()) return v8::Local<Value>(); | 2302 if (!maybe.FromJust()) return v8::Local<Value>(); |
2303 Local<Value> result; | 2303 Local<Value> result; |
2304 has_pending_exception = | 2304 has_pending_exception = |
2305 !ToLocal<Value>(i::JSReceiver::GetProperty(obj, name), &result); | 2305 !ToLocal<Value>(i::JSReceiver::GetProperty(obj, name), &result); |
2306 RETURN_ON_FAILED_EXECUTION(Value); | 2306 RETURN_ON_FAILED_EXECUTION(Value); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2388 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2389 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2389 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2390 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2390 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
2391 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); | 2391 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); |
2392 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); | 2392 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); |
2393 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); | 2393 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); |
2394 } | 2394 } |
2395 | 2395 |
2396 | 2396 |
2397 Maybe<int> Message::GetLineNumber(Local<Context> context) const { | 2397 Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
2398 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int); | 2398 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetLineNumber, int); |
2399 i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); | 2399 i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); |
2400 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2400 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2401 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2401 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
2402 i::Handle<i::Object> result; | 2402 i::Handle<i::Object> result; |
2403 has_pending_exception = | 2403 has_pending_exception = |
2404 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2404 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
2405 .ToHandle(&result); | 2405 .ToHandle(&result); |
2406 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2406 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2407 return Just(static_cast<int>(result->Number())); | 2407 return Just(static_cast<int>(result->Number())); |
2408 } | 2408 } |
(...skipping 11 matching lines...) Expand all Loading... |
2420 } | 2420 } |
2421 | 2421 |
2422 | 2422 |
2423 int Message::GetEndPosition() const { | 2423 int Message::GetEndPosition() const { |
2424 auto self = Utils::OpenHandle(this); | 2424 auto self = Utils::OpenHandle(this); |
2425 return self->end_position(); | 2425 return self->end_position(); |
2426 } | 2426 } |
2427 | 2427 |
2428 | 2428 |
2429 Maybe<int> Message::GetStartColumn(Local<Context> context) const { | 2429 Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
2430 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()", | 2430 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetStartColumn, int); |
2431 int); | |
2432 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2431 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
2433 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2432 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2434 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2433 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
2435 i::Handle<i::Object> result; | 2434 i::Handle<i::Object> result; |
2436 has_pending_exception = | 2435 has_pending_exception = |
2437 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2436 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
2438 .ToHandle(&result); | 2437 .ToHandle(&result); |
2439 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2438 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2440 return Just(static_cast<int>(result->Number())); | 2439 return Just(static_cast<int>(result->Number())); |
2441 } | 2440 } |
2442 | 2441 |
2443 | 2442 |
2444 int Message::GetStartColumn() const { | 2443 int Message::GetStartColumn() const { |
2445 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2444 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
2446 const int default_value = kNoColumnInfo; | 2445 const int default_value = kNoColumnInfo; |
2447 return GetStartColumn(context).FromMaybe(default_value); | 2446 return GetStartColumn(context).FromMaybe(default_value); |
2448 } | 2447 } |
2449 | 2448 |
2450 | 2449 |
2451 Maybe<int> Message::GetEndColumn(Local<Context> context) const { | 2450 Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
2452 auto self = Utils::OpenHandle(this); | 2451 auto self = Utils::OpenHandle(this); |
2453 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); | 2452 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetEndColumn, int); |
2454 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2453 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
2455 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2454 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2456 i::Handle<i::Object> args[] = {self}; | 2455 i::Handle<i::Object> args[] = {self}; |
2457 i::Handle<i::Object> result; | 2456 i::Handle<i::Object> result; |
2458 has_pending_exception = | 2457 has_pending_exception = |
2459 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2458 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
2460 .ToHandle(&result); | 2459 .ToHandle(&result); |
2461 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2460 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
2462 int start = self->start_position(); | 2461 int start = self->start_position(); |
2463 int end = self->end_position(); | 2462 int end = self->end_position(); |
(...skipping 23 matching lines...) Expand all Loading... |
2487 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2486 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2488 ENTER_V8(isolate); | 2487 ENTER_V8(isolate); |
2489 auto self = Utils::OpenHandle(this); | 2488 auto self = Utils::OpenHandle(this); |
2490 auto script = i::Handle<i::JSValue>::cast( | 2489 auto script = i::Handle<i::JSValue>::cast( |
2491 i::Handle<i::Object>(self->script(), isolate)); | 2490 i::Handle<i::Object>(self->script(), isolate)); |
2492 return i::Script::cast(script->value())->origin_options().IsOpaque(); | 2491 return i::Script::cast(script->value())->origin_options().IsOpaque(); |
2493 } | 2492 } |
2494 | 2493 |
2495 | 2494 |
2496 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { | 2495 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
2497 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); | 2496 PREPARE_FOR_EXECUTION(context, Message, GetSourceLine, String); |
2498 i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); | 2497 i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); |
2499 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2498 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
2500 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2499 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
2501 i::Handle<i::Object> result; | 2500 i::Handle<i::Object> result; |
2502 has_pending_exception = | 2501 has_pending_exception = |
2503 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2502 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
2504 .ToHandle(&result); | 2503 .ToHandle(&result); |
2505 RETURN_ON_FAILED_EXECUTION(String); | 2504 RETURN_ON_FAILED_EXECUTION(String); |
2506 Local<String> str; | 2505 Local<String> str; |
2507 if (result->IsString()) { | 2506 if (result->IsString()) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 } | 2731 } |
2733 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); | 2732 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); |
2734 return i::JSWeakCollection::Delete(weak_collection, key, hash); | 2733 return i::JSWeakCollection::Delete(weak_collection, key, hash); |
2735 } | 2734 } |
2736 | 2735 |
2737 | 2736 |
2738 // --- J S O N --- | 2737 // --- J S O N --- |
2739 | 2738 |
2740 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { | 2739 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { |
2741 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2740 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
2742 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Parse", Value); | 2741 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, JSON, Parse, Value); |
2743 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2742 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
2744 i::Handle<i::String> source = i::String::Flatten(string); | 2743 i::Handle<i::String> source = i::String::Flatten(string); |
2745 auto maybe = source->IsSeqOneByteString() | 2744 auto maybe = source->IsSeqOneByteString() |
2746 ? i::JsonParser<true>::Parse(source) | 2745 ? i::JsonParser<true>::Parse(source) |
2747 : i::JsonParser<false>::Parse(source); | 2746 : i::JsonParser<false>::Parse(source); |
2748 Local<Value> result; | 2747 Local<Value> result; |
2749 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2748 has_pending_exception = !ToLocal<Value>(maybe, &result); |
2750 RETURN_ON_FAILED_EXECUTION(Value); | 2749 RETURN_ON_FAILED_EXECUTION(Value); |
2751 RETURN_ESCAPED(result); | 2750 RETURN_ESCAPED(result); |
2752 } | 2751 } |
2753 | 2752 |
2754 MaybeLocal<Value> JSON::Parse(Local<Context> context, | 2753 MaybeLocal<Value> JSON::Parse(Local<Context> context, |
2755 Local<String> json_string) { | 2754 Local<String> json_string) { |
2756 PREPARE_FOR_EXECUTION(context, "JSON::Parse", Value); | 2755 PREPARE_FOR_EXECUTION(context, JSON, Parse, Value); |
2757 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2756 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
2758 i::Handle<i::String> source = i::String::Flatten(string); | 2757 i::Handle<i::String> source = i::String::Flatten(string); |
2759 auto maybe = source->IsSeqOneByteString() | 2758 auto maybe = source->IsSeqOneByteString() |
2760 ? i::JsonParser<true>::Parse(source) | 2759 ? i::JsonParser<true>::Parse(source) |
2761 : i::JsonParser<false>::Parse(source); | 2760 : i::JsonParser<false>::Parse(source); |
2762 Local<Value> result; | 2761 Local<Value> result; |
2763 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2762 has_pending_exception = !ToLocal<Value>(maybe, &result); |
2764 RETURN_ON_FAILED_EXECUTION(Value); | 2763 RETURN_ON_FAILED_EXECUTION(Value); |
2765 RETURN_ESCAPED(result); | 2764 RETURN_ESCAPED(result); |
2766 } | 2765 } |
2767 | 2766 |
2768 Local<Value> JSON::Parse(Local<String> json_string) { | 2767 Local<Value> JSON::Parse(Local<String> json_string) { |
2769 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); | 2768 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); |
2770 } | 2769 } |
2771 | 2770 |
2772 MaybeLocal<String> JSON::Stringify(Local<Context> context, | 2771 MaybeLocal<String> JSON::Stringify(Local<Context> context, |
2773 Local<Object> json_object) { | 2772 Local<Object> json_object) { |
2774 PREPARE_FOR_EXECUTION(context, "JSON::Stringify", String); | 2773 PREPARE_FOR_EXECUTION(context, JSON, Stringify, String); |
2775 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); | 2774 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); |
2776 i::Handle<i::Object> maybe; | 2775 i::Handle<i::Object> maybe; |
2777 has_pending_exception = | 2776 has_pending_exception = |
2778 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); | 2777 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); |
2779 RETURN_ON_FAILED_EXECUTION(String); | 2778 RETURN_ON_FAILED_EXECUTION(String); |
2780 Local<String> result; | 2779 Local<String> result; |
2781 has_pending_exception = | 2780 has_pending_exception = |
2782 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); | 2781 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); |
2783 RETURN_ON_FAILED_EXECUTION(String); | 2782 RETURN_ON_FAILED_EXECUTION(String); |
2784 RETURN_ESCAPED(result); | 2783 RETURN_ESCAPED(result); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2993 | 2992 |
2994 bool Value::IsPromise() const { | 2993 bool Value::IsPromise() const { |
2995 auto self = Utils::OpenHandle(this); | 2994 auto self = Utils::OpenHandle(this); |
2996 return i::Object::IsPromise(self); | 2995 return i::Object::IsPromise(self); |
2997 } | 2996 } |
2998 | 2997 |
2999 | 2998 |
3000 MaybeLocal<String> Value::ToString(Local<Context> context) const { | 2999 MaybeLocal<String> Value::ToString(Local<Context> context) const { |
3001 auto obj = Utils::OpenHandle(this); | 3000 auto obj = Utils::OpenHandle(this); |
3002 if (obj->IsString()) return ToApiHandle<String>(obj); | 3001 if (obj->IsString()) return ToApiHandle<String>(obj); |
3003 PREPARE_FOR_EXECUTION(context, "ToString", String); | 3002 PREPARE_FOR_EXECUTION(context, Object, ToString, String); |
3004 Local<String> result; | 3003 Local<String> result; |
3005 has_pending_exception = | 3004 has_pending_exception = |
3006 !ToLocal<String>(i::Object::ToString(isolate, obj), &result); | 3005 !ToLocal<String>(i::Object::ToString(isolate, obj), &result); |
3007 RETURN_ON_FAILED_EXECUTION(String); | 3006 RETURN_ON_FAILED_EXECUTION(String); |
3008 RETURN_ESCAPED(result); | 3007 RETURN_ESCAPED(result); |
3009 } | 3008 } |
3010 | 3009 |
3011 | 3010 |
3012 Local<String> Value::ToString(Isolate* isolate) const { | 3011 Local<String> Value::ToString(Isolate* isolate) const { |
3013 RETURN_TO_LOCAL_UNCHECKED(ToString(isolate->GetCurrentContext()), String); | 3012 RETURN_TO_LOCAL_UNCHECKED(ToString(isolate->GetCurrentContext()), String); |
3014 } | 3013 } |
3015 | 3014 |
3016 | 3015 |
3017 MaybeLocal<String> Value::ToDetailString(Local<Context> context) const { | 3016 MaybeLocal<String> Value::ToDetailString(Local<Context> context) const { |
3018 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3017 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3019 if (obj->IsString()) return ToApiHandle<String>(obj); | 3018 if (obj->IsString()) return ToApiHandle<String>(obj); |
3020 PREPARE_FOR_EXECUTION(context, "ToDetailString", String); | 3019 PREPARE_FOR_EXECUTION(context, Object, ToDetailString, String); |
3021 Local<String> result; | 3020 Local<String> result; |
3022 i::Handle<i::Object> args[] = {obj}; | 3021 i::Handle<i::Object> args[] = {obj}; |
3023 has_pending_exception = !ToLocal<String>( | 3022 has_pending_exception = !ToLocal<String>( |
3024 i::Execution::TryCall(isolate, isolate->no_side_effects_to_string_fun(), | 3023 i::Execution::TryCall(isolate, isolate->no_side_effects_to_string_fun(), |
3025 isolate->factory()->undefined_value(), | 3024 isolate->factory()->undefined_value(), |
3026 arraysize(args), args), | 3025 arraysize(args), args), |
3027 &result); | 3026 &result); |
3028 RETURN_ON_FAILED_EXECUTION(String); | 3027 RETURN_ON_FAILED_EXECUTION(String); |
3029 RETURN_ESCAPED(result); | 3028 RETURN_ESCAPED(result); |
3030 } | 3029 } |
3031 | 3030 |
3032 | 3031 |
3033 Local<String> Value::ToDetailString(Isolate* isolate) const { | 3032 Local<String> Value::ToDetailString(Isolate* isolate) const { |
3034 RETURN_TO_LOCAL_UNCHECKED(ToDetailString(isolate->GetCurrentContext()), | 3033 RETURN_TO_LOCAL_UNCHECKED(ToDetailString(isolate->GetCurrentContext()), |
3035 String); | 3034 String); |
3036 } | 3035 } |
3037 | 3036 |
3038 | 3037 |
3039 MaybeLocal<Object> Value::ToObject(Local<Context> context) const { | 3038 MaybeLocal<Object> Value::ToObject(Local<Context> context) const { |
3040 auto obj = Utils::OpenHandle(this); | 3039 auto obj = Utils::OpenHandle(this); |
3041 if (obj->IsJSReceiver()) return ToApiHandle<Object>(obj); | 3040 if (obj->IsJSReceiver()) return ToApiHandle<Object>(obj); |
3042 PREPARE_FOR_EXECUTION(context, "ToObject", Object); | 3041 PREPARE_FOR_EXECUTION(context, Object, ToObject, Object); |
3043 Local<Object> result; | 3042 Local<Object> result; |
3044 has_pending_exception = | 3043 has_pending_exception = |
3045 !ToLocal<Object>(i::Object::ToObject(isolate, obj), &result); | 3044 !ToLocal<Object>(i::Object::ToObject(isolate, obj), &result); |
3046 RETURN_ON_FAILED_EXECUTION(Object); | 3045 RETURN_ON_FAILED_EXECUTION(Object); |
3047 RETURN_ESCAPED(result); | 3046 RETURN_ESCAPED(result); |
3048 } | 3047 } |
3049 | 3048 |
3050 | 3049 |
3051 Local<v8::Object> Value::ToObject(Isolate* isolate) const { | 3050 Local<v8::Object> Value::ToObject(Isolate* isolate) const { |
3052 RETURN_TO_LOCAL_UNCHECKED(ToObject(isolate->GetCurrentContext()), Object); | 3051 RETURN_TO_LOCAL_UNCHECKED(ToObject(isolate->GetCurrentContext()), Object); |
(...skipping 10 matching lines...) Expand all Loading... |
3063 | 3062 |
3064 | 3063 |
3065 Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const { | 3064 Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const { |
3066 return ToBoolean(v8_isolate->GetCurrentContext()).ToLocalChecked(); | 3065 return ToBoolean(v8_isolate->GetCurrentContext()).ToLocalChecked(); |
3067 } | 3066 } |
3068 | 3067 |
3069 | 3068 |
3070 MaybeLocal<Number> Value::ToNumber(Local<Context> context) const { | 3069 MaybeLocal<Number> Value::ToNumber(Local<Context> context) const { |
3071 auto obj = Utils::OpenHandle(this); | 3070 auto obj = Utils::OpenHandle(this); |
3072 if (obj->IsNumber()) return ToApiHandle<Number>(obj); | 3071 if (obj->IsNumber()) return ToApiHandle<Number>(obj); |
3073 PREPARE_FOR_EXECUTION(context, "ToNumber", Number); | 3072 PREPARE_FOR_EXECUTION(context, Object, ToNumber, Number); |
3074 Local<Number> result; | 3073 Local<Number> result; |
3075 has_pending_exception = !ToLocal<Number>(i::Object::ToNumber(obj), &result); | 3074 has_pending_exception = !ToLocal<Number>(i::Object::ToNumber(obj), &result); |
3076 RETURN_ON_FAILED_EXECUTION(Number); | 3075 RETURN_ON_FAILED_EXECUTION(Number); |
3077 RETURN_ESCAPED(result); | 3076 RETURN_ESCAPED(result); |
3078 } | 3077 } |
3079 | 3078 |
3080 | 3079 |
3081 Local<Number> Value::ToNumber(Isolate* isolate) const { | 3080 Local<Number> Value::ToNumber(Isolate* isolate) const { |
3082 RETURN_TO_LOCAL_UNCHECKED(ToNumber(isolate->GetCurrentContext()), Number); | 3081 RETURN_TO_LOCAL_UNCHECKED(ToNumber(isolate->GetCurrentContext()), Number); |
3083 } | 3082 } |
3084 | 3083 |
3085 | 3084 |
3086 MaybeLocal<Integer> Value::ToInteger(Local<Context> context) const { | 3085 MaybeLocal<Integer> Value::ToInteger(Local<Context> context) const { |
3087 auto obj = Utils::OpenHandle(this); | 3086 auto obj = Utils::OpenHandle(this); |
3088 if (obj->IsSmi()) return ToApiHandle<Integer>(obj); | 3087 if (obj->IsSmi()) return ToApiHandle<Integer>(obj); |
3089 PREPARE_FOR_EXECUTION(context, "ToInteger", Integer); | 3088 PREPARE_FOR_EXECUTION(context, Object, ToInteger, Integer); |
3090 Local<Integer> result; | 3089 Local<Integer> result; |
3091 has_pending_exception = | 3090 has_pending_exception = |
3092 !ToLocal<Integer>(i::Object::ToInteger(isolate, obj), &result); | 3091 !ToLocal<Integer>(i::Object::ToInteger(isolate, obj), &result); |
3093 RETURN_ON_FAILED_EXECUTION(Integer); | 3092 RETURN_ON_FAILED_EXECUTION(Integer); |
3094 RETURN_ESCAPED(result); | 3093 RETURN_ESCAPED(result); |
3095 } | 3094 } |
3096 | 3095 |
3097 | 3096 |
3098 Local<Integer> Value::ToInteger(Isolate* isolate) const { | 3097 Local<Integer> Value::ToInteger(Isolate* isolate) const { |
3099 RETURN_TO_LOCAL_UNCHECKED(ToInteger(isolate->GetCurrentContext()), Integer); | 3098 RETURN_TO_LOCAL_UNCHECKED(ToInteger(isolate->GetCurrentContext()), Integer); |
3100 } | 3099 } |
3101 | 3100 |
3102 | 3101 |
3103 MaybeLocal<Int32> Value::ToInt32(Local<Context> context) const { | 3102 MaybeLocal<Int32> Value::ToInt32(Local<Context> context) const { |
3104 auto obj = Utils::OpenHandle(this); | 3103 auto obj = Utils::OpenHandle(this); |
3105 if (obj->IsSmi()) return ToApiHandle<Int32>(obj); | 3104 if (obj->IsSmi()) return ToApiHandle<Int32>(obj); |
3106 Local<Int32> result; | 3105 Local<Int32> result; |
3107 PREPARE_FOR_EXECUTION(context, "ToInt32", Int32); | 3106 PREPARE_FOR_EXECUTION(context, Object, ToInt32, Int32); |
3108 has_pending_exception = | 3107 has_pending_exception = |
3109 !ToLocal<Int32>(i::Object::ToInt32(isolate, obj), &result); | 3108 !ToLocal<Int32>(i::Object::ToInt32(isolate, obj), &result); |
3110 RETURN_ON_FAILED_EXECUTION(Int32); | 3109 RETURN_ON_FAILED_EXECUTION(Int32); |
3111 RETURN_ESCAPED(result); | 3110 RETURN_ESCAPED(result); |
3112 } | 3111 } |
3113 | 3112 |
3114 | 3113 |
3115 Local<Int32> Value::ToInt32(Isolate* isolate) const { | 3114 Local<Int32> Value::ToInt32(Isolate* isolate) const { |
3116 RETURN_TO_LOCAL_UNCHECKED(ToInt32(isolate->GetCurrentContext()), Int32); | 3115 RETURN_TO_LOCAL_UNCHECKED(ToInt32(isolate->GetCurrentContext()), Int32); |
3117 } | 3116 } |
3118 | 3117 |
3119 | 3118 |
3120 MaybeLocal<Uint32> Value::ToUint32(Local<Context> context) const { | 3119 MaybeLocal<Uint32> Value::ToUint32(Local<Context> context) const { |
3121 auto obj = Utils::OpenHandle(this); | 3120 auto obj = Utils::OpenHandle(this); |
3122 if (obj->IsSmi()) return ToApiHandle<Uint32>(obj); | 3121 if (obj->IsSmi()) return ToApiHandle<Uint32>(obj); |
3123 Local<Uint32> result; | 3122 Local<Uint32> result; |
3124 PREPARE_FOR_EXECUTION(context, "ToUint32", Uint32); | 3123 PREPARE_FOR_EXECUTION(context, Object, ToUint32, Uint32); |
3125 has_pending_exception = | 3124 has_pending_exception = |
3126 !ToLocal<Uint32>(i::Object::ToUint32(isolate, obj), &result); | 3125 !ToLocal<Uint32>(i::Object::ToUint32(isolate, obj), &result); |
3127 RETURN_ON_FAILED_EXECUTION(Uint32); | 3126 RETURN_ON_FAILED_EXECUTION(Uint32); |
3128 RETURN_ESCAPED(result); | 3127 RETURN_ESCAPED(result); |
3129 } | 3128 } |
3130 | 3129 |
3131 | 3130 |
3132 Local<Uint32> Value::ToUint32(Isolate* isolate) const { | 3131 Local<Uint32> Value::ToUint32(Isolate* isolate) const { |
3133 RETURN_TO_LOCAL_UNCHECKED(ToUint32(isolate->GetCurrentContext()), Uint32); | 3132 RETURN_TO_LOCAL_UNCHECKED(ToUint32(isolate->GetCurrentContext()), Uint32); |
3134 } | 3133 } |
3135 | 3134 |
3136 | 3135 |
3137 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { | 3136 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { |
3138 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 3137 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
3139 Utils::ApiCheck(isolate != NULL && | 3138 Utils::ApiCheck(isolate != NULL && !isolate->IsDead(), |
3140 !isolate->IsDead(), | 3139 "v8::internal::Internals::CheckInitialized", |
3141 "v8::internal::Internals::CheckInitialized()", | |
3142 "Isolate is not initialized or V8 has died"); | 3140 "Isolate is not initialized or V8 has died"); |
3143 } | 3141 } |
3144 | 3142 |
3145 | 3143 |
3146 void External::CheckCast(v8::Value* that) { | 3144 void External::CheckCast(v8::Value* that) { |
3147 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 3145 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), "v8::External::Cast", |
3148 "v8::External::Cast()", | |
3149 "Could not convert to external"); | 3146 "Could not convert to external"); |
3150 } | 3147 } |
3151 | 3148 |
3152 | 3149 |
3153 void v8::Object::CheckCast(Value* that) { | 3150 void v8::Object::CheckCast(Value* that) { |
3154 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3151 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3155 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()", | 3152 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast", |
3156 "Could not convert to object"); | 3153 "Could not convert to object"); |
3157 } | 3154 } |
3158 | 3155 |
3159 | 3156 |
3160 void v8::Function::CheckCast(Value* that) { | 3157 void v8::Function::CheckCast(Value* that) { |
3161 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3158 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3162 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", | 3159 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast", |
3163 "Could not convert to function"); | 3160 "Could not convert to function"); |
3164 } | 3161 } |
3165 | 3162 |
3166 | 3163 |
3167 void v8::Boolean::CheckCast(v8::Value* that) { | 3164 void v8::Boolean::CheckCast(v8::Value* that) { |
3168 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3165 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3169 Utils::ApiCheck(obj->IsBoolean(), | 3166 Utils::ApiCheck(obj->IsBoolean(), "v8::Boolean::Cast", |
3170 "v8::Boolean::Cast()", | |
3171 "Could not convert to boolean"); | 3167 "Could not convert to boolean"); |
3172 } | 3168 } |
3173 | 3169 |
3174 | 3170 |
3175 void v8::Name::CheckCast(v8::Value* that) { | 3171 void v8::Name::CheckCast(v8::Value* that) { |
3176 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3172 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3177 Utils::ApiCheck(obj->IsName(), | 3173 Utils::ApiCheck(obj->IsName(), "v8::Name::Cast", "Could not convert to name"); |
3178 "v8::Name::Cast()", | |
3179 "Could not convert to name"); | |
3180 } | 3174 } |
3181 | 3175 |
3182 | 3176 |
3183 void v8::String::CheckCast(v8::Value* that) { | 3177 void v8::String::CheckCast(v8::Value* that) { |
3184 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3178 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3185 Utils::ApiCheck(obj->IsString(), | 3179 Utils::ApiCheck(obj->IsString(), "v8::String::Cast", |
3186 "v8::String::Cast()", | |
3187 "Could not convert to string"); | 3180 "Could not convert to string"); |
3188 } | 3181 } |
3189 | 3182 |
3190 | 3183 |
3191 void v8::Symbol::CheckCast(v8::Value* that) { | 3184 void v8::Symbol::CheckCast(v8::Value* that) { |
3192 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3185 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3193 Utils::ApiCheck(obj->IsSymbol(), | 3186 Utils::ApiCheck(obj->IsSymbol(), "v8::Symbol::Cast", |
3194 "v8::Symbol::Cast()", | |
3195 "Could not convert to symbol"); | 3187 "Could not convert to symbol"); |
3196 } | 3188 } |
3197 | 3189 |
3198 | 3190 |
3199 void v8::Number::CheckCast(v8::Value* that) { | 3191 void v8::Number::CheckCast(v8::Value* that) { |
3200 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3192 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3201 Utils::ApiCheck(obj->IsNumber(), | 3193 Utils::ApiCheck(obj->IsNumber(), |
3202 "v8::Number::Cast()", | 3194 "v8::Number::Cast()", |
3203 "Could not convert to number"); | 3195 "Could not convert to number"); |
3204 } | 3196 } |
3205 | 3197 |
3206 | 3198 |
3207 void v8::Integer::CheckCast(v8::Value* that) { | 3199 void v8::Integer::CheckCast(v8::Value* that) { |
3208 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3200 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3209 Utils::ApiCheck(obj->IsNumber(), | 3201 Utils::ApiCheck(obj->IsNumber(), "v8::Integer::Cast", |
3210 "v8::Integer::Cast()", | |
3211 "Could not convert to number"); | 3202 "Could not convert to number"); |
3212 } | 3203 } |
3213 | 3204 |
3214 | 3205 |
3215 void v8::Int32::CheckCast(v8::Value* that) { | 3206 void v8::Int32::CheckCast(v8::Value* that) { |
3216 Utils::ApiCheck(that->IsInt32(), "v8::Int32::Cast()", | 3207 Utils::ApiCheck(that->IsInt32(), "v8::Int32::Cast", |
3217 "Could not convert to 32-bit signed integer"); | 3208 "Could not convert to 32-bit signed integer"); |
3218 } | 3209 } |
3219 | 3210 |
3220 | 3211 |
3221 void v8::Uint32::CheckCast(v8::Value* that) { | 3212 void v8::Uint32::CheckCast(v8::Value* that) { |
3222 Utils::ApiCheck(that->IsUint32(), "v8::Uint32::Cast()", | 3213 Utils::ApiCheck(that->IsUint32(), "v8::Uint32::Cast", |
3223 "Could not convert to 32-bit unsigned integer"); | 3214 "Could not convert to 32-bit unsigned integer"); |
3224 } | 3215 } |
3225 | 3216 |
3226 | 3217 |
3227 void v8::Array::CheckCast(Value* that) { | 3218 void v8::Array::CheckCast(Value* that) { |
3228 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3219 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3229 Utils::ApiCheck(obj->IsJSArray(), | 3220 Utils::ApiCheck(obj->IsJSArray(), "v8::Array::Cast", |
3230 "v8::Array::Cast()", | |
3231 "Could not convert to array"); | 3221 "Could not convert to array"); |
3232 } | 3222 } |
3233 | 3223 |
3234 | 3224 |
3235 void v8::Map::CheckCast(Value* that) { | 3225 void v8::Map::CheckCast(Value* that) { |
3236 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3226 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3237 Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast()", | 3227 Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast", "Could not convert to Map"); |
3238 "Could not convert to Map"); | |
3239 } | 3228 } |
3240 | 3229 |
3241 | 3230 |
3242 void v8::Set::CheckCast(Value* that) { | 3231 void v8::Set::CheckCast(Value* that) { |
3243 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3232 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3244 Utils::ApiCheck(obj->IsJSSet(), "v8::Set::Cast()", | 3233 Utils::ApiCheck(obj->IsJSSet(), "v8_Set_Cast", "Could not convert to Set"); |
3245 "Could not convert to Set"); | |
3246 } | 3234 } |
3247 | 3235 |
3248 | 3236 |
3249 void v8::Promise::CheckCast(Value* that) { | 3237 void v8::Promise::CheckCast(Value* that) { |
3250 Utils::ApiCheck(that->IsPromise(), | 3238 Utils::ApiCheck(that->IsPromise(), "v8::Promise::Cast", |
3251 "v8::Promise::Cast()", | |
3252 "Could not convert to promise"); | 3239 "Could not convert to promise"); |
3253 } | 3240 } |
3254 | 3241 |
3255 | 3242 |
3256 void v8::Promise::Resolver::CheckCast(Value* that) { | 3243 void v8::Promise::Resolver::CheckCast(Value* that) { |
3257 Utils::ApiCheck(that->IsPromise(), | 3244 Utils::ApiCheck(that->IsPromise(), "v8::Promise::Resolver::Cast", |
3258 "v8::Promise::Resolver::Cast()", | |
3259 "Could not convert to promise resolver"); | 3245 "Could not convert to promise resolver"); |
3260 } | 3246 } |
3261 | 3247 |
3262 | 3248 |
3263 void v8::Proxy::CheckCast(Value* that) { | 3249 void v8::Proxy::CheckCast(Value* that) { |
3264 Utils::ApiCheck(that->IsProxy(), "v8::Proxy::Cast()", | 3250 Utils::ApiCheck(that->IsProxy(), "v8::Proxy::Cast", |
3265 "Could not convert to proxy"); | 3251 "Could not convert to proxy"); |
3266 } | 3252 } |
3267 | 3253 |
3268 | 3254 |
3269 void v8::ArrayBuffer::CheckCast(Value* that) { | 3255 void v8::ArrayBuffer::CheckCast(Value* that) { |
3270 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3256 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
3271 Utils::ApiCheck( | 3257 Utils::ApiCheck( |
3272 obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(), | 3258 obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(), |
3273 "v8::ArrayBuffer::Cast()", "Could not convert to ArrayBuffer"); | 3259 "v8::ArrayBuffer::Cast()", "Could not convert to ArrayBuffer"); |
3274 } | 3260 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3391 | 3377 |
3392 | 3378 |
3393 bool Value::BooleanValue() const { | 3379 bool Value::BooleanValue() const { |
3394 return Utils::OpenHandle(this)->BooleanValue(); | 3380 return Utils::OpenHandle(this)->BooleanValue(); |
3395 } | 3381 } |
3396 | 3382 |
3397 | 3383 |
3398 Maybe<double> Value::NumberValue(Local<Context> context) const { | 3384 Maybe<double> Value::NumberValue(Local<Context> context) const { |
3399 auto obj = Utils::OpenHandle(this); | 3385 auto obj = Utils::OpenHandle(this); |
3400 if (obj->IsNumber()) return Just(obj->Number()); | 3386 if (obj->IsNumber()) return Just(obj->Number()); |
3401 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "NumberValue", double); | 3387 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, NumberValue, double); |
3402 i::Handle<i::Object> num; | 3388 i::Handle<i::Object> num; |
3403 has_pending_exception = !i::Object::ToNumber(obj).ToHandle(&num); | 3389 has_pending_exception = !i::Object::ToNumber(obj).ToHandle(&num); |
3404 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(double); | 3390 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(double); |
3405 return Just(num->Number()); | 3391 return Just(num->Number()); |
3406 } | 3392 } |
3407 | 3393 |
3408 | 3394 |
3409 double Value::NumberValue() const { | 3395 double Value::NumberValue() const { |
3410 auto obj = Utils::OpenHandle(this); | 3396 auto obj = Utils::OpenHandle(this); |
3411 if (obj->IsNumber()) return obj->Number(); | 3397 if (obj->IsNumber()) return obj->Number(); |
3412 return NumberValue(ContextFromHeapObject(obj)) | 3398 return NumberValue(ContextFromHeapObject(obj)) |
3413 .FromMaybe(std::numeric_limits<double>::quiet_NaN()); | 3399 .FromMaybe(std::numeric_limits<double>::quiet_NaN()); |
3414 } | 3400 } |
3415 | 3401 |
3416 | 3402 |
3417 Maybe<int64_t> Value::IntegerValue(Local<Context> context) const { | 3403 Maybe<int64_t> Value::IntegerValue(Local<Context> context) const { |
3418 auto obj = Utils::OpenHandle(this); | 3404 auto obj = Utils::OpenHandle(this); |
3419 if (obj->IsNumber()) { | 3405 if (obj->IsNumber()) { |
3420 return Just(NumberToInt64(*obj)); | 3406 return Just(NumberToInt64(*obj)); |
3421 } | 3407 } |
3422 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "IntegerValue", int64_t); | 3408 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, IntegerValue, int64_t); |
3423 i::Handle<i::Object> num; | 3409 i::Handle<i::Object> num; |
3424 has_pending_exception = !i::Object::ToInteger(isolate, obj).ToHandle(&num); | 3410 has_pending_exception = !i::Object::ToInteger(isolate, obj).ToHandle(&num); |
3425 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t); | 3411 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t); |
3426 return Just(NumberToInt64(*num)); | 3412 return Just(NumberToInt64(*num)); |
3427 } | 3413 } |
3428 | 3414 |
3429 | 3415 |
3430 int64_t Value::IntegerValue() const { | 3416 int64_t Value::IntegerValue() const { |
3431 auto obj = Utils::OpenHandle(this); | 3417 auto obj = Utils::OpenHandle(this); |
3432 if (obj->IsNumber()) { | 3418 if (obj->IsNumber()) { |
3433 if (obj->IsSmi()) { | 3419 if (obj->IsSmi()) { |
3434 return i::Smi::cast(*obj)->value(); | 3420 return i::Smi::cast(*obj)->value(); |
3435 } else { | 3421 } else { |
3436 return static_cast<int64_t>(obj->Number()); | 3422 return static_cast<int64_t>(obj->Number()); |
3437 } | 3423 } |
3438 } | 3424 } |
3439 return IntegerValue(ContextFromHeapObject(obj)).FromMaybe(0); | 3425 return IntegerValue(ContextFromHeapObject(obj)).FromMaybe(0); |
3440 } | 3426 } |
3441 | 3427 |
3442 | 3428 |
3443 Maybe<int32_t> Value::Int32Value(Local<Context> context) const { | 3429 Maybe<int32_t> Value::Int32Value(Local<Context> context) const { |
3444 auto obj = Utils::OpenHandle(this); | 3430 auto obj = Utils::OpenHandle(this); |
3445 if (obj->IsNumber()) return Just(NumberToInt32(*obj)); | 3431 if (obj->IsNumber()) return Just(NumberToInt32(*obj)); |
3446 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Int32Value", int32_t); | 3432 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Int32Value, int32_t); |
3447 i::Handle<i::Object> num; | 3433 i::Handle<i::Object> num; |
3448 has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num); | 3434 has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num); |
3449 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t); | 3435 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t); |
3450 return Just(num->IsSmi() ? i::Smi::cast(*num)->value() | 3436 return Just(num->IsSmi() ? i::Smi::cast(*num)->value() |
3451 : static_cast<int32_t>(num->Number())); | 3437 : static_cast<int32_t>(num->Number())); |
3452 } | 3438 } |
3453 | 3439 |
3454 | 3440 |
3455 int32_t Value::Int32Value() const { | 3441 int32_t Value::Int32Value() const { |
3456 auto obj = Utils::OpenHandle(this); | 3442 auto obj = Utils::OpenHandle(this); |
3457 if (obj->IsNumber()) return NumberToInt32(*obj); | 3443 if (obj->IsNumber()) return NumberToInt32(*obj); |
3458 return Int32Value(ContextFromHeapObject(obj)).FromMaybe(0); | 3444 return Int32Value(ContextFromHeapObject(obj)).FromMaybe(0); |
3459 } | 3445 } |
3460 | 3446 |
3461 | 3447 |
3462 Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const { | 3448 Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const { |
3463 auto obj = Utils::OpenHandle(this); | 3449 auto obj = Utils::OpenHandle(this); |
3464 if (obj->IsNumber()) return Just(NumberToUint32(*obj)); | 3450 if (obj->IsNumber()) return Just(NumberToUint32(*obj)); |
3465 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Uint32Value", uint32_t); | 3451 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Uint32Value, uint32_t); |
3466 i::Handle<i::Object> num; | 3452 i::Handle<i::Object> num; |
3467 has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num); | 3453 has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num); |
3468 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t); | 3454 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t); |
3469 return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value()) | 3455 return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value()) |
3470 : static_cast<uint32_t>(num->Number())); | 3456 : static_cast<uint32_t>(num->Number())); |
3471 } | 3457 } |
3472 | 3458 |
3473 | 3459 |
3474 uint32_t Value::Uint32Value() const { | 3460 uint32_t Value::Uint32Value() const { |
3475 auto obj = Utils::OpenHandle(this); | 3461 auto obj = Utils::OpenHandle(this); |
3476 if (obj->IsNumber()) return NumberToUint32(*obj); | 3462 if (obj->IsNumber()) return NumberToUint32(*obj); |
3477 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0); | 3463 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0); |
3478 } | 3464 } |
3479 | 3465 |
3480 | 3466 |
3481 MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const { | 3467 MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const { |
3482 auto self = Utils::OpenHandle(this); | 3468 auto self = Utils::OpenHandle(this); |
3483 if (self->IsSmi()) { | 3469 if (self->IsSmi()) { |
3484 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); | 3470 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); |
3485 return Local<Uint32>(); | 3471 return Local<Uint32>(); |
3486 } | 3472 } |
3487 PREPARE_FOR_EXECUTION(context, "ToArrayIndex", Uint32); | 3473 PREPARE_FOR_EXECUTION(context, Object, ToArrayIndex, Uint32); |
3488 i::Handle<i::Object> string_obj; | 3474 i::Handle<i::Object> string_obj; |
3489 has_pending_exception = | 3475 has_pending_exception = |
3490 !i::Object::ToString(isolate, self).ToHandle(&string_obj); | 3476 !i::Object::ToString(isolate, self).ToHandle(&string_obj); |
3491 RETURN_ON_FAILED_EXECUTION(Uint32); | 3477 RETURN_ON_FAILED_EXECUTION(Uint32); |
3492 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); | 3478 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); |
3493 uint32_t index; | 3479 uint32_t index; |
3494 if (str->AsArrayIndex(&index)) { | 3480 if (str->AsArrayIndex(&index)) { |
3495 i::Handle<i::Object> value; | 3481 i::Handle<i::Object> value; |
3496 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { | 3482 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { |
3497 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); | 3483 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3546 | 3532 |
3547 bool Value::SameValue(Local<Value> that) const { | 3533 bool Value::SameValue(Local<Value> that) const { |
3548 auto self = Utils::OpenHandle(this); | 3534 auto self = Utils::OpenHandle(this); |
3549 auto other = Utils::OpenHandle(*that); | 3535 auto other = Utils::OpenHandle(*that); |
3550 return self->SameValue(*other); | 3536 return self->SameValue(*other); |
3551 } | 3537 } |
3552 | 3538 |
3553 Local<String> Value::TypeOf(v8::Isolate* external_isolate) { | 3539 Local<String> Value::TypeOf(v8::Isolate* external_isolate) { |
3554 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 3540 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
3555 ENTER_V8(isolate); | 3541 ENTER_V8(isolate); |
3556 LOG_API(isolate, "v8::Value::TypeOf()"); | 3542 LOG_API(isolate, Value, TypeOf); |
3557 return Utils::ToLocal(i::Object::TypeOf(isolate, Utils::OpenHandle(this))); | 3543 return Utils::ToLocal(i::Object::TypeOf(isolate, Utils::OpenHandle(this))); |
3558 } | 3544 } |
3559 | 3545 |
3560 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, | 3546 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, |
3561 v8::Local<Value> key, v8::Local<Value> value) { | 3547 v8::Local<Value> key, v8::Local<Value> value) { |
3562 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3548 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Set, bool); |
3563 auto self = Utils::OpenHandle(this); | 3549 auto self = Utils::OpenHandle(this); |
3564 auto key_obj = Utils::OpenHandle(*key); | 3550 auto key_obj = Utils::OpenHandle(*key); |
3565 auto value_obj = Utils::OpenHandle(*value); | 3551 auto value_obj = Utils::OpenHandle(*value); |
3566 has_pending_exception = | 3552 has_pending_exception = |
3567 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, | 3553 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, |
3568 i::SLOPPY).is_null(); | 3554 i::SLOPPY).is_null(); |
3569 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3555 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3570 return Just(true); | 3556 return Just(true); |
3571 } | 3557 } |
3572 | 3558 |
3573 | 3559 |
3574 bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) { | 3560 bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) { |
3575 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3561 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3576 return Set(context, key, value).FromMaybe(false); | 3562 return Set(context, key, value).FromMaybe(false); |
3577 } | 3563 } |
3578 | 3564 |
3579 | 3565 |
3580 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, | 3566 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, |
3581 v8::Local<Value> value) { | 3567 v8::Local<Value> value) { |
3582 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3568 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Set, bool); |
3583 auto self = Utils::OpenHandle(this); | 3569 auto self = Utils::OpenHandle(this); |
3584 auto value_obj = Utils::OpenHandle(*value); | 3570 auto value_obj = Utils::OpenHandle(*value); |
3585 has_pending_exception = i::Object::SetElement(isolate, self, index, value_obj, | 3571 has_pending_exception = i::Object::SetElement(isolate, self, index, value_obj, |
3586 i::SLOPPY).is_null(); | 3572 i::SLOPPY).is_null(); |
3587 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3573 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3588 return Just(true); | 3574 return Just(true); |
3589 } | 3575 } |
3590 | 3576 |
3591 | 3577 |
3592 bool v8::Object::Set(uint32_t index, v8::Local<Value> value) { | 3578 bool v8::Object::Set(uint32_t index, v8::Local<Value> value) { |
3593 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3579 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3594 return Set(context, index, value).FromMaybe(false); | 3580 return Set(context, index, value).FromMaybe(false); |
3595 } | 3581 } |
3596 | 3582 |
3597 | 3583 |
3598 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3584 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
3599 v8::Local<Name> key, | 3585 v8::Local<Name> key, |
3600 v8::Local<Value> value) { | 3586 v8::Local<Value> value) { |
3601 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3587 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, CreateDataProperty, bool); |
3602 bool); | |
3603 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3588 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3604 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3589 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
3605 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3590 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3606 | 3591 |
3607 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 3592 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
3608 isolate, self, key_obj, self, i::LookupIterator::OWN); | 3593 isolate, self, key_obj, self, i::LookupIterator::OWN); |
3609 Maybe<bool> result = | 3594 Maybe<bool> result = |
3610 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); | 3595 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); |
3611 has_pending_exception = result.IsNothing(); | 3596 has_pending_exception = result.IsNothing(); |
3612 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3597 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3613 return result; | 3598 return result; |
3614 } | 3599 } |
3615 | 3600 |
3616 | 3601 |
3617 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3602 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
3618 uint32_t index, | 3603 uint32_t index, |
3619 v8::Local<Value> value) { | 3604 v8::Local<Value> value) { |
3620 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3605 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, CreateDataProperty, bool); |
3621 bool); | |
3622 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3606 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3623 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3607 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3624 | 3608 |
3625 i::LookupIterator it(isolate, self, index, self, i::LookupIterator::OWN); | 3609 i::LookupIterator it(isolate, self, index, self, i::LookupIterator::OWN); |
3626 Maybe<bool> result = | 3610 Maybe<bool> result = |
3627 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); | 3611 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); |
3628 has_pending_exception = result.IsNothing(); | 3612 has_pending_exception = result.IsNothing(); |
3629 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3613 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3630 return result; | 3614 return result; |
3631 } | 3615 } |
3632 | 3616 |
3633 | 3617 |
3634 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, | 3618 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
3635 v8::Local<Name> key, | 3619 v8::Local<Name> key, |
3636 v8::Local<Value> value, | 3620 v8::Local<Value> value, |
3637 v8::PropertyAttribute attributes) { | 3621 v8::PropertyAttribute attributes) { |
3638 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", | 3622 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DefineOwnProperty, bool); |
3639 bool); | |
3640 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3623 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3641 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3624 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
3642 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3625 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3643 | 3626 |
3644 if (self->IsAccessCheckNeeded() && | 3627 if (self->IsAccessCheckNeeded() && |
3645 !isolate->MayAccess(handle(isolate->context()), | 3628 !isolate->MayAccess(handle(isolate->context()), |
3646 i::Handle<i::JSObject>::cast(self))) { | 3629 i::Handle<i::JSObject>::cast(self))) { |
3647 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); | 3630 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); |
3648 return Nothing<bool>(); | 3631 return Nothing<bool>(); |
3649 } | 3632 } |
(...skipping 22 matching lines...) Expand all Loading... |
3672 if (!success) return i::MaybeHandle<i::Object>(); | 3655 if (!success) return i::MaybeHandle<i::Object>(); |
3673 | 3656 |
3674 return i::JSObject::DefineOwnPropertyIgnoreAttributes( | 3657 return i::JSObject::DefineOwnPropertyIgnoreAttributes( |
3675 &it, value, attrs, i::JSObject::FORCE_FIELD); | 3658 &it, value, attrs, i::JSObject::FORCE_FIELD); |
3676 } | 3659 } |
3677 | 3660 |
3678 | 3661 |
3679 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3662 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
3680 v8::Local<Value> key, v8::Local<Value> value, | 3663 v8::Local<Value> key, v8::Local<Value> value, |
3681 v8::PropertyAttribute attribs) { | 3664 v8::PropertyAttribute attribs) { |
3682 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); | 3665 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, ForceSet, bool); |
3683 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3666 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3684 auto key_obj = Utils::OpenHandle(*key); | 3667 auto key_obj = Utils::OpenHandle(*key); |
3685 auto value_obj = Utils::OpenHandle(*value); | 3668 auto value_obj = Utils::OpenHandle(*value); |
3686 has_pending_exception = | 3669 has_pending_exception = |
3687 DefineObjectProperty(self, key_obj, value_obj, | 3670 DefineObjectProperty(self, key_obj, value_obj, |
3688 static_cast<i::PropertyAttributes>(attribs)) | 3671 static_cast<i::PropertyAttributes>(attribs)) |
3689 .is_null(); | 3672 .is_null(); |
3690 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3673 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3691 return Just(true); | 3674 return Just(true); |
3692 } | 3675 } |
3693 | 3676 |
3694 | 3677 |
3695 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, | 3678 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
3696 v8::PropertyAttribute attribs) { | 3679 v8::PropertyAttribute attribs) { |
3697 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3680 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3698 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), | 3681 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), Object, ForceSet, |
3699 "v8::Object::ForceSet", false, i::HandleScope, | 3682 false, i::HandleScope, false); |
3700 false); | |
3701 i::Handle<i::JSObject> self = | 3683 i::Handle<i::JSObject> self = |
3702 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3684 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
3703 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3685 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3704 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3686 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3705 has_pending_exception = | 3687 has_pending_exception = |
3706 DefineObjectProperty(self, key_obj, value_obj, | 3688 DefineObjectProperty(self, key_obj, value_obj, |
3707 static_cast<i::PropertyAttributes>(attribs)) | 3689 static_cast<i::PropertyAttributes>(attribs)) |
3708 .is_null(); | 3690 .is_null(); |
3709 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3691 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
3710 return true; | 3692 return true; |
3711 } | 3693 } |
3712 | 3694 |
3713 | 3695 |
3714 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, | 3696 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, |
3715 Local<Value> value) { | 3697 Local<Value> value) { |
3716 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrivate()", bool); | 3698 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetPrivate, bool); |
3717 auto self = Utils::OpenHandle(this); | 3699 auto self = Utils::OpenHandle(this); |
3718 auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); | 3700 auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); |
3719 auto value_obj = Utils::OpenHandle(*value); | 3701 auto value_obj = Utils::OpenHandle(*value); |
3720 if (self->IsJSProxy()) { | 3702 if (self->IsJSProxy()) { |
3721 i::PropertyDescriptor desc; | 3703 i::PropertyDescriptor desc; |
3722 desc.set_writable(true); | 3704 desc.set_writable(true); |
3723 desc.set_enumerable(false); | 3705 desc.set_enumerable(false); |
3724 desc.set_configurable(true); | 3706 desc.set_configurable(true); |
3725 desc.set_value(value_obj); | 3707 desc.set_value(value_obj); |
3726 return i::JSProxy::SetPrivateProperty( | 3708 return i::JSProxy::SetPrivateProperty( |
3727 isolate, i::Handle<i::JSProxy>::cast(self), | 3709 isolate, i::Handle<i::JSProxy>::cast(self), |
3728 i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW); | 3710 i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW); |
3729 } | 3711 } |
3730 auto js_object = i::Handle<i::JSObject>::cast(self); | 3712 auto js_object = i::Handle<i::JSObject>::cast(self); |
3731 i::LookupIterator it(js_object, key_obj, js_object); | 3713 i::LookupIterator it(js_object, key_obj, js_object); |
3732 has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( | 3714 has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( |
3733 &it, value_obj, i::DONT_ENUM) | 3715 &it, value_obj, i::DONT_ENUM) |
3734 .is_null(); | 3716 .is_null(); |
3735 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3717 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3736 return Just(true); | 3718 return Just(true); |
3737 } | 3719 } |
3738 | 3720 |
3739 | 3721 |
3740 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3722 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
3741 Local<Value> key) { | 3723 Local<Value> key) { |
3742 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3724 PREPARE_FOR_EXECUTION(context, Object, Get, Value); |
3743 auto self = Utils::OpenHandle(this); | 3725 auto self = Utils::OpenHandle(this); |
3744 auto key_obj = Utils::OpenHandle(*key); | 3726 auto key_obj = Utils::OpenHandle(*key); |
3745 i::Handle<i::Object> result; | 3727 i::Handle<i::Object> result; |
3746 has_pending_exception = | 3728 has_pending_exception = |
3747 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); | 3729 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); |
3748 RETURN_ON_FAILED_EXECUTION(Value); | 3730 RETURN_ON_FAILED_EXECUTION(Value); |
3749 RETURN_ESCAPED(Utils::ToLocal(result)); | 3731 RETURN_ESCAPED(Utils::ToLocal(result)); |
3750 } | 3732 } |
3751 | 3733 |
3752 | 3734 |
3753 Local<Value> v8::Object::Get(v8::Local<Value> key) { | 3735 Local<Value> v8::Object::Get(v8::Local<Value> key) { |
3754 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3736 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3755 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); | 3737 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); |
3756 } | 3738 } |
3757 | 3739 |
3758 | 3740 |
3759 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { | 3741 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { |
3760 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3742 PREPARE_FOR_EXECUTION(context, Object, Get, Value); |
3761 auto self = Utils::OpenHandle(this); | 3743 auto self = Utils::OpenHandle(this); |
3762 i::Handle<i::Object> result; | 3744 i::Handle<i::Object> result; |
3763 has_pending_exception = | 3745 has_pending_exception = |
3764 !i::JSReceiver::GetElement(isolate, self, index).ToHandle(&result); | 3746 !i::JSReceiver::GetElement(isolate, self, index).ToHandle(&result); |
3765 RETURN_ON_FAILED_EXECUTION(Value); | 3747 RETURN_ON_FAILED_EXECUTION(Value); |
3766 RETURN_ESCAPED(Utils::ToLocal(result)); | 3748 RETURN_ESCAPED(Utils::ToLocal(result)); |
3767 } | 3749 } |
3768 | 3750 |
3769 | 3751 |
3770 Local<Value> v8::Object::Get(uint32_t index) { | 3752 Local<Value> v8::Object::Get(uint32_t index) { |
3771 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3753 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3772 RETURN_TO_LOCAL_UNCHECKED(Get(context, index), Value); | 3754 RETURN_TO_LOCAL_UNCHECKED(Get(context, index), Value); |
3773 } | 3755 } |
3774 | 3756 |
3775 | 3757 |
3776 MaybeLocal<Value> v8::Object::GetPrivate(Local<Context> context, | 3758 MaybeLocal<Value> v8::Object::GetPrivate(Local<Context> context, |
3777 Local<Private> key) { | 3759 Local<Private> key) { |
3778 return Get(context, Local<Value>(reinterpret_cast<Value*>(*key))); | 3760 return Get(context, Local<Value>(reinterpret_cast<Value*>(*key))); |
3779 } | 3761 } |
3780 | 3762 |
3781 | 3763 |
3782 Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes( | 3764 Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes( |
3783 Local<Context> context, Local<Value> key) { | 3765 Local<Context> context, Local<Value> key) { |
3784 PREPARE_FOR_EXECUTION_PRIMITIVE( | 3766 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, GetPropertyAttributes, |
3785 context, "v8::Object::GetPropertyAttributes()", PropertyAttribute); | 3767 PropertyAttribute); |
3786 auto self = Utils::OpenHandle(this); | 3768 auto self = Utils::OpenHandle(this); |
3787 auto key_obj = Utils::OpenHandle(*key); | 3769 auto key_obj = Utils::OpenHandle(*key); |
3788 if (!key_obj->IsName()) { | 3770 if (!key_obj->IsName()) { |
3789 has_pending_exception = | 3771 has_pending_exception = |
3790 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); | 3772 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); |
3791 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3773 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
3792 } | 3774 } |
3793 auto key_name = i::Handle<i::Name>::cast(key_obj); | 3775 auto key_name = i::Handle<i::Name>::cast(key_obj); |
3794 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); | 3776 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); |
3795 has_pending_exception = result.IsNothing(); | 3777 has_pending_exception = result.IsNothing(); |
3796 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3778 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
3797 if (result.FromJust() == i::ABSENT) { | 3779 if (result.FromJust() == i::ABSENT) { |
3798 return Just(static_cast<PropertyAttribute>(i::NONE)); | 3780 return Just(static_cast<PropertyAttribute>(i::NONE)); |
3799 } | 3781 } |
3800 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 3782 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
3801 } | 3783 } |
3802 | 3784 |
3803 | 3785 |
3804 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { | 3786 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { |
3805 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3787 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3806 return GetPropertyAttributes(context, key) | 3788 return GetPropertyAttributes(context, key) |
3807 .FromMaybe(static_cast<PropertyAttribute>(i::NONE)); | 3789 .FromMaybe(static_cast<PropertyAttribute>(i::NONE)); |
3808 } | 3790 } |
3809 | 3791 |
3810 | 3792 |
3811 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, | 3793 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, |
3812 Local<String> key) { | 3794 Local<String> key) { |
3813 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", | 3795 PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyDescriptor, Value); |
3814 Value); | |
3815 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); | 3796 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
3816 i::Handle<i::String> key_name = Utils::OpenHandle(*key); | 3797 i::Handle<i::String> key_name = Utils::OpenHandle(*key); |
3817 | 3798 |
3818 i::PropertyDescriptor desc; | 3799 i::PropertyDescriptor desc; |
3819 Maybe<bool> found = | 3800 Maybe<bool> found = |
3820 i::JSReceiver::GetOwnPropertyDescriptor(isolate, obj, key_name, &desc); | 3801 i::JSReceiver::GetOwnPropertyDescriptor(isolate, obj, key_name, &desc); |
3821 has_pending_exception = found.IsNothing(); | 3802 has_pending_exception = found.IsNothing(); |
3822 RETURN_ON_FAILED_EXECUTION(Value); | 3803 RETURN_ON_FAILED_EXECUTION(Value); |
3823 if (!found.FromJust()) { | 3804 if (!found.FromJust()) { |
3824 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 3805 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
(...skipping 11 matching lines...) Expand all Loading... |
3836 Local<Value> v8::Object::GetPrototype() { | 3817 Local<Value> v8::Object::GetPrototype() { |
3837 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 3818 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
3838 auto self = Utils::OpenHandle(this); | 3819 auto self = Utils::OpenHandle(this); |
3839 i::PrototypeIterator iter(isolate, self); | 3820 i::PrototypeIterator iter(isolate, self); |
3840 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); | 3821 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); |
3841 } | 3822 } |
3842 | 3823 |
3843 | 3824 |
3844 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, | 3825 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, |
3845 Local<Value> value) { | 3826 Local<Value> value) { |
3846 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); | 3827 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetPrototype, bool); |
3847 auto self = Utils::OpenHandle(this); | 3828 auto self = Utils::OpenHandle(this); |
3848 auto value_obj = Utils::OpenHandle(*value); | 3829 auto value_obj = Utils::OpenHandle(*value); |
3849 // We do not allow exceptions thrown while setting the prototype | 3830 // We do not allow exceptions thrown while setting the prototype |
3850 // to propagate outside. | 3831 // to propagate outside. |
3851 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 3832 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
3852 auto result = i::JSReceiver::SetPrototype(self, value_obj, false, | 3833 auto result = i::JSReceiver::SetPrototype(self, value_obj, false, |
3853 i::Object::THROW_ON_ERROR); | 3834 i::Object::THROW_ON_ERROR); |
3854 has_pending_exception = result.IsNothing(); | 3835 has_pending_exception = result.IsNothing(); |
3855 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3836 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3856 return Just(true); | 3837 return Just(true); |
(...skipping 17 matching lines...) Expand all Loading... |
3874 if (iter.IsAtEnd()) { | 3855 if (iter.IsAtEnd()) { |
3875 return Local<Object>(); | 3856 return Local<Object>(); |
3876 } | 3857 } |
3877 } | 3858 } |
3878 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. | 3859 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
3879 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); | 3860 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
3880 } | 3861 } |
3881 | 3862 |
3882 | 3863 |
3883 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { | 3864 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
3884 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); | 3865 PREPARE_FOR_EXECUTION(context, Object, GetPropertyNames, Array); |
3885 auto self = Utils::OpenHandle(this); | 3866 auto self = Utils::OpenHandle(this); |
3886 i::Handle<i::FixedArray> value; | 3867 i::Handle<i::FixedArray> value; |
3887 has_pending_exception = | 3868 has_pending_exception = |
3888 !i::JSReceiver::GetKeys(self, i::INCLUDE_PROTOS, i::ENUMERABLE_STRINGS) | 3869 !i::JSReceiver::GetKeys(self, i::INCLUDE_PROTOS, i::ENUMERABLE_STRINGS) |
3889 .ToHandle(&value); | 3870 .ToHandle(&value); |
3890 RETURN_ON_FAILED_EXECUTION(Array); | 3871 RETURN_ON_FAILED_EXECUTION(Array); |
3891 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | 3872 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
3892 self->map()->EnumLength() == 0 || | 3873 self->map()->EnumLength() == 0 || |
3893 self->map()->instance_descriptors()->GetEnumCache() != *value); | 3874 self->map()->instance_descriptors()->GetEnumCache() != *value); |
3894 auto result = isolate->factory()->NewJSArrayWithElements(value); | 3875 auto result = isolate->factory()->NewJSArrayWithElements(value); |
3895 RETURN_ESCAPED(Utils::ToLocal(result)); | 3876 RETURN_ESCAPED(Utils::ToLocal(result)); |
3896 } | 3877 } |
3897 | 3878 |
3898 | 3879 |
3899 Local<Array> v8::Object::GetPropertyNames() { | 3880 Local<Array> v8::Object::GetPropertyNames() { |
3900 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3881 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3901 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); | 3882 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); |
3902 } | 3883 } |
3903 | 3884 |
3904 | |
3905 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { | 3885 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { |
3906 return GetOwnPropertyNames( | 3886 return GetOwnPropertyNames( |
3907 context, static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS)); | 3887 context, static_cast<v8::PropertyFilter>(ONLY_ENUMERABLE | SKIP_SYMBOLS)); |
3908 } | 3888 } |
3909 | 3889 |
3910 Local<Array> v8::Object::GetOwnPropertyNames() { | 3890 Local<Array> v8::Object::GetOwnPropertyNames() { |
3911 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3891 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3912 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); | 3892 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); |
3913 } | 3893 } |
3914 | 3894 |
3915 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context, | 3895 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context, |
3916 PropertyFilter filter) { | 3896 PropertyFilter filter) { |
3917 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array); | 3897 PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyNames, Array); |
3918 auto self = Utils::OpenHandle(this); | 3898 auto self = Utils::OpenHandle(this); |
3919 i::Handle<i::FixedArray> value; | 3899 i::Handle<i::FixedArray> value; |
3920 has_pending_exception = | 3900 has_pending_exception = |
3921 !i::JSReceiver::GetKeys(self, i::OWN_ONLY, | 3901 !i::JSReceiver::GetKeys(self, i::OWN_ONLY, |
3922 static_cast<i::PropertyFilter>(filter)) | 3902 static_cast<i::PropertyFilter>(filter)) |
3923 .ToHandle(&value); | 3903 .ToHandle(&value); |
3924 RETURN_ON_FAILED_EXECUTION(Array); | 3904 RETURN_ON_FAILED_EXECUTION(Array); |
3925 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | 3905 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
3926 self->map()->EnumLength() == 0 || | 3906 self->map()->EnumLength() == 0 || |
3927 self->map()->instance_descriptors()->GetEnumCache() != *value); | 3907 self->map()->instance_descriptors()->GetEnumCache() != *value); |
3928 auto result = isolate->factory()->NewJSArrayWithElements(value); | 3908 auto result = isolate->factory()->NewJSArrayWithElements(value); |
3929 RETURN_ESCAPED(Utils::ToLocal(result)); | 3909 RETURN_ESCAPED(Utils::ToLocal(result)); |
3930 } | 3910 } |
3931 | 3911 |
3932 | |
3933 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { | 3912 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { |
3934 PREPARE_FOR_EXECUTION(context, "v8::Object::ObjectProtoToString", String); | 3913 PREPARE_FOR_EXECUTION(context, Object, ObjectProtoToString, String); |
3935 auto obj = Utils::OpenHandle(this); | 3914 auto obj = Utils::OpenHandle(this); |
3936 Local<String> result; | 3915 Local<String> result; |
3937 has_pending_exception = | 3916 has_pending_exception = |
3938 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); | 3917 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); |
3939 RETURN_ON_FAILED_EXECUTION(String); | 3918 RETURN_ON_FAILED_EXECUTION(String); |
3940 RETURN_ESCAPED(result); | 3919 RETURN_ESCAPED(result); |
3941 } | 3920 } |
3942 | 3921 |
3943 | 3922 |
3944 Local<String> v8::Object::ObjectProtoToString() { | 3923 Local<String> v8::Object::ObjectProtoToString() { |
3945 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3924 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3946 RETURN_TO_LOCAL_UNCHECKED(ObjectProtoToString(context), String); | 3925 RETURN_TO_LOCAL_UNCHECKED(ObjectProtoToString(context), String); |
3947 } | 3926 } |
3948 | 3927 |
3949 | 3928 |
3950 Local<String> v8::Object::GetConstructorName() { | 3929 Local<String> v8::Object::GetConstructorName() { |
3951 auto self = Utils::OpenHandle(this); | 3930 auto self = Utils::OpenHandle(this); |
3952 i::Handle<i::String> name = i::JSReceiver::GetConstructorName(self); | 3931 i::Handle<i::String> name = i::JSReceiver::GetConstructorName(self); |
3953 return Utils::ToLocal(name); | 3932 return Utils::ToLocal(name); |
3954 } | 3933 } |
3955 | 3934 |
3956 Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context, | 3935 Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context, |
3957 IntegrityLevel level) { | 3936 IntegrityLevel level) { |
3958 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetIntegrityLevel()", | 3937 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetIntegrityLevel, bool); |
3959 bool); | |
3960 auto self = Utils::OpenHandle(this); | 3938 auto self = Utils::OpenHandle(this); |
3961 i::JSReceiver::IntegrityLevel i_level = | 3939 i::JSReceiver::IntegrityLevel i_level = |
3962 level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED; | 3940 level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED; |
3963 Maybe<bool> result = | 3941 Maybe<bool> result = |
3964 i::JSReceiver::SetIntegrityLevel(self, i_level, i::Object::DONT_THROW); | 3942 i::JSReceiver::SetIntegrityLevel(self, i_level, i::Object::DONT_THROW); |
3965 has_pending_exception = result.IsNothing(); | 3943 has_pending_exception = result.IsNothing(); |
3966 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3944 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3967 return result; | 3945 return result; |
3968 } | 3946 } |
3969 | 3947 |
3970 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { | 3948 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { |
3971 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool); | 3949 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Delete, bool); |
3972 auto self = Utils::OpenHandle(this); | 3950 auto self = Utils::OpenHandle(this); |
3973 auto key_obj = Utils::OpenHandle(*key); | 3951 auto key_obj = Utils::OpenHandle(*key); |
3974 Maybe<bool> result = | 3952 Maybe<bool> result = |
3975 i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY); | 3953 i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY); |
3976 has_pending_exception = result.IsNothing(); | 3954 has_pending_exception = result.IsNothing(); |
3977 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3955 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3978 return result; | 3956 return result; |
3979 } | 3957 } |
3980 | 3958 |
3981 | 3959 |
3982 bool v8::Object::Delete(v8::Local<Value> key) { | 3960 bool v8::Object::Delete(v8::Local<Value> key) { |
3983 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3961 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3984 return Delete(context, key).FromMaybe(false); | 3962 return Delete(context, key).FromMaybe(false); |
3985 } | 3963 } |
3986 | 3964 |
3987 | 3965 |
3988 Maybe<bool> v8::Object::DeletePrivate(Local<Context> context, | 3966 Maybe<bool> v8::Object::DeletePrivate(Local<Context> context, |
3989 Local<Private> key) { | 3967 Local<Private> key) { |
3990 return Delete(context, Local<Value>(reinterpret_cast<Value*>(*key))); | 3968 return Delete(context, Local<Value>(reinterpret_cast<Value*>(*key))); |
3991 } | 3969 } |
3992 | 3970 |
3993 | 3971 |
3994 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { | 3972 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { |
3995 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 3973 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Get, bool); |
3996 auto self = Utils::OpenHandle(this); | 3974 auto self = Utils::OpenHandle(this); |
3997 auto key_obj = Utils::OpenHandle(*key); | 3975 auto key_obj = Utils::OpenHandle(*key); |
3998 Maybe<bool> maybe = Nothing<bool>(); | 3976 Maybe<bool> maybe = Nothing<bool>(); |
3999 // Check if the given key is an array index. | 3977 // Check if the given key is an array index. |
4000 uint32_t index = 0; | 3978 uint32_t index = 0; |
4001 if (key_obj->ToArrayIndex(&index)) { | 3979 if (key_obj->ToArrayIndex(&index)) { |
4002 maybe = i::JSReceiver::HasElement(self, index); | 3980 maybe = i::JSReceiver::HasElement(self, index); |
4003 } else { | 3981 } else { |
4004 // Convert the key to a name - possibly by calling back into JavaScript. | 3982 // Convert the key to a name - possibly by calling back into JavaScript. |
4005 i::Handle<i::Name> name; | 3983 i::Handle<i::Name> name; |
(...skipping 12 matching lines...) Expand all Loading... |
4018 return Has(context, key).FromMaybe(false); | 3996 return Has(context, key).FromMaybe(false); |
4019 } | 3997 } |
4020 | 3998 |
4021 | 3999 |
4022 Maybe<bool> v8::Object::HasPrivate(Local<Context> context, Local<Private> key) { | 4000 Maybe<bool> v8::Object::HasPrivate(Local<Context> context, Local<Private> key) { |
4023 return HasOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key))); | 4001 return HasOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key))); |
4024 } | 4002 } |
4025 | 4003 |
4026 | 4004 |
4027 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { | 4005 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { |
4028 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DeleteProperty()", | 4006 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, DeleteProperty, bool); |
4029 bool); | |
4030 auto self = Utils::OpenHandle(this); | 4007 auto self = Utils::OpenHandle(this); |
4031 Maybe<bool> result = i::JSReceiver::DeleteElement(self, index); | 4008 Maybe<bool> result = i::JSReceiver::DeleteElement(self, index); |
4032 has_pending_exception = result.IsNothing(); | 4009 has_pending_exception = result.IsNothing(); |
4033 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4010 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4034 return result; | 4011 return result; |
4035 } | 4012 } |
4036 | 4013 |
4037 | 4014 |
4038 bool v8::Object::Delete(uint32_t index) { | 4015 bool v8::Object::Delete(uint32_t index) { |
4039 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4016 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4040 return Delete(context, index).FromMaybe(false); | 4017 return Delete(context, index).FromMaybe(false); |
4041 } | 4018 } |
4042 | 4019 |
4043 | 4020 |
4044 Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) { | 4021 Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) { |
4045 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 4022 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, Get, bool); |
4046 auto self = Utils::OpenHandle(this); | 4023 auto self = Utils::OpenHandle(this); |
4047 auto maybe = i::JSReceiver::HasElement(self, index); | 4024 auto maybe = i::JSReceiver::HasElement(self, index); |
4048 has_pending_exception = maybe.IsNothing(); | 4025 has_pending_exception = maybe.IsNothing(); |
4049 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4026 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4050 return maybe; | 4027 return maybe; |
4051 } | 4028 } |
4052 | 4029 |
4053 | 4030 |
4054 bool v8::Object::Has(uint32_t index) { | 4031 bool v8::Object::Has(uint32_t index) { |
4055 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4032 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4056 return Has(context, index).FromMaybe(false); | 4033 return Has(context, index).FromMaybe(false); |
4057 } | 4034 } |
4058 | 4035 |
4059 | 4036 |
4060 template <typename Getter, typename Setter, typename Data> | 4037 template <typename Getter, typename Setter, typename Data> |
4061 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, | 4038 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, |
4062 Local<Name> name, Getter getter, | 4039 Local<Name> name, Getter getter, |
4063 Setter setter, Data data, | 4040 Setter setter, Data data, |
4064 AccessControl settings, | 4041 AccessControl settings, |
4065 PropertyAttribute attributes) { | 4042 PropertyAttribute attributes) { |
4066 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); | 4043 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, SetAccessor, bool); |
4067 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); | 4044 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); |
4068 i::Handle<i::JSObject> obj = | 4045 i::Handle<i::JSObject> obj = |
4069 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); | 4046 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); |
4070 v8::Local<AccessorSignature> signature; | 4047 v8::Local<AccessorSignature> signature; |
4071 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, | 4048 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, |
4072 signature, i::FLAG_disable_old_api_accessors); | 4049 signature, i::FLAG_disable_old_api_accessors); |
4073 if (info.is_null()) return Nothing<bool>(); | 4050 if (info.is_null()) return Nothing<bool>(); |
4074 bool fast = obj->HasFastProperties(); | 4051 bool fast = obj->HasFastProperties(); |
4075 i::Handle<i::Object> result; | 4052 i::Handle<i::Object> result; |
4076 has_pending_exception = | 4053 has_pending_exception = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4128 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 4105 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
4129 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 4106 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
4130 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), | 4107 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), |
4131 v8::Utils::OpenHandle(*name), getter_i, setter_i, | 4108 v8::Utils::OpenHandle(*name), getter_i, setter_i, |
4132 static_cast<i::PropertyAttributes>(attribute)); | 4109 static_cast<i::PropertyAttributes>(attribute)); |
4133 } | 4110 } |
4134 | 4111 |
4135 | 4112 |
4136 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, | 4113 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, |
4137 Local<Name> key) { | 4114 Local<Name> key) { |
4138 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", | 4115 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasOwnProperty, bool); |
4139 bool); | |
4140 auto self = Utils::OpenHandle(this); | 4116 auto self = Utils::OpenHandle(this); |
4141 auto key_val = Utils::OpenHandle(*key); | 4117 auto key_val = Utils::OpenHandle(*key); |
4142 auto result = i::JSReceiver::HasOwnProperty(self, key_val); | 4118 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
4143 has_pending_exception = result.IsNothing(); | 4119 has_pending_exception = result.IsNothing(); |
4144 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4120 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4145 return result; | 4121 return result; |
4146 } | 4122 } |
4147 | 4123 |
4148 | 4124 |
4149 bool v8::Object::HasOwnProperty(Local<String> key) { | 4125 bool v8::Object::HasOwnProperty(Local<String> key) { |
4150 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4126 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4151 return HasOwnProperty(context, key).FromMaybe(false); | 4127 return HasOwnProperty(context, key).FromMaybe(false); |
4152 } | 4128 } |
4153 | 4129 |
4154 | 4130 |
4155 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, | 4131 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
4156 Local<Name> key) { | 4132 Local<Name> key) { |
4157 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", | 4133 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealNamedProperty, bool); |
4158 bool); | |
4159 auto self = Utils::OpenHandle(this); | 4134 auto self = Utils::OpenHandle(this); |
4160 if (!self->IsJSObject()) return Just(false); | 4135 if (!self->IsJSObject()) return Just(false); |
4161 auto key_val = Utils::OpenHandle(*key); | 4136 auto key_val = Utils::OpenHandle(*key); |
4162 auto result = i::JSObject::HasRealNamedProperty( | 4137 auto result = i::JSObject::HasRealNamedProperty( |
4163 i::Handle<i::JSObject>::cast(self), key_val); | 4138 i::Handle<i::JSObject>::cast(self), key_val); |
4164 has_pending_exception = result.IsNothing(); | 4139 has_pending_exception = result.IsNothing(); |
4165 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4140 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4166 return result; | 4141 return result; |
4167 } | 4142 } |
4168 | 4143 |
4169 | 4144 |
4170 bool v8::Object::HasRealNamedProperty(Local<String> key) { | 4145 bool v8::Object::HasRealNamedProperty(Local<String> key) { |
4171 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4146 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4172 return HasRealNamedProperty(context, key).FromMaybe(false); | 4147 return HasRealNamedProperty(context, key).FromMaybe(false); |
4173 } | 4148 } |
4174 | 4149 |
4175 | 4150 |
4176 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, | 4151 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
4177 uint32_t index) { | 4152 uint32_t index) { |
4178 PREPARE_FOR_EXECUTION_PRIMITIVE(context, | 4153 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealIndexedProperty, |
4179 "v8::Object::HasRealIndexedProperty()", bool); | 4154 bool); |
4180 auto self = Utils::OpenHandle(this); | 4155 auto self = Utils::OpenHandle(this); |
4181 if (!self->IsJSObject()) return Just(false); | 4156 if (!self->IsJSObject()) return Just(false); |
4182 auto result = i::JSObject::HasRealElementProperty( | 4157 auto result = i::JSObject::HasRealElementProperty( |
4183 i::Handle<i::JSObject>::cast(self), index); | 4158 i::Handle<i::JSObject>::cast(self), index); |
4184 has_pending_exception = result.IsNothing(); | 4159 has_pending_exception = result.IsNothing(); |
4185 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4160 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4186 return result; | 4161 return result; |
4187 } | 4162 } |
4188 | 4163 |
4189 | 4164 |
4190 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 4165 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
4191 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4166 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4192 return HasRealIndexedProperty(context, index).FromMaybe(false); | 4167 return HasRealIndexedProperty(context, index).FromMaybe(false); |
4193 } | 4168 } |
4194 | 4169 |
4195 | 4170 |
4196 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, | 4171 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, |
4197 Local<Name> key) { | 4172 Local<Name> key) { |
4198 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4173 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Object, HasRealNamedCallbackProperty, |
4199 context, "v8::Object::HasRealNamedCallbackProperty()", bool); | 4174 bool); |
4200 auto self = Utils::OpenHandle(this); | 4175 auto self = Utils::OpenHandle(this); |
4201 if (!self->IsJSObject()) return Just(false); | 4176 if (!self->IsJSObject()) return Just(false); |
4202 auto key_val = Utils::OpenHandle(*key); | 4177 auto key_val = Utils::OpenHandle(*key); |
4203 auto result = i::JSObject::HasRealNamedCallbackProperty( | 4178 auto result = i::JSObject::HasRealNamedCallbackProperty( |
4204 i::Handle<i::JSObject>::cast(self), key_val); | 4179 i::Handle<i::JSObject>::cast(self), key_val); |
4205 has_pending_exception = result.IsNothing(); | 4180 has_pending_exception = result.IsNothing(); |
4206 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4181 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4207 return result; | 4182 return result; |
4208 } | 4183 } |
4209 | 4184 |
(...skipping 13 matching lines...) Expand all Loading... |
4223 | 4198 |
4224 bool v8::Object::HasIndexedLookupInterceptor() { | 4199 bool v8::Object::HasIndexedLookupInterceptor() { |
4225 auto self = Utils::OpenHandle(this); | 4200 auto self = Utils::OpenHandle(this); |
4226 return self->IsJSObject() && | 4201 return self->IsJSObject() && |
4227 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); | 4202 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); |
4228 } | 4203 } |
4229 | 4204 |
4230 | 4205 |
4231 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4206 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
4232 Local<Context> context, Local<Name> key) { | 4207 Local<Context> context, Local<Name> key) { |
4233 PREPARE_FOR_EXECUTION( | 4208 PREPARE_FOR_EXECUTION(context, Object, GetRealNamedPropertyInPrototypeChain, |
4234 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); | 4209 Value); |
4235 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 4210 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
4236 if (!self->IsJSObject()) return MaybeLocal<Value>(); | 4211 if (!self->IsJSObject()) return MaybeLocal<Value>(); |
4237 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4212 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
4238 i::PrototypeIterator iter(isolate, self); | 4213 i::PrototypeIterator iter(isolate, self); |
4239 if (iter.IsAtEnd()) return MaybeLocal<Value>(); | 4214 if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
4240 i::Handle<i::JSReceiver> proto = | 4215 i::Handle<i::JSReceiver> proto = |
4241 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4216 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
4242 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4217 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4243 isolate, self, key_obj, proto, | 4218 isolate, self, key_obj, proto, |
4244 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4219 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
(...skipping 10 matching lines...) Expand all Loading... |
4255 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4230 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4256 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), | 4231 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), |
4257 Value); | 4232 Value); |
4258 } | 4233 } |
4259 | 4234 |
4260 | 4235 |
4261 Maybe<PropertyAttribute> | 4236 Maybe<PropertyAttribute> |
4262 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( | 4237 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
4263 Local<Context> context, Local<Name> key) { | 4238 Local<Context> context, Local<Name> key) { |
4264 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4239 PREPARE_FOR_EXECUTION_PRIMITIVE( |
4265 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", | 4240 context, Object, GetRealNamedPropertyAttributesInPrototypeChain, |
4266 PropertyAttribute); | 4241 PropertyAttribute); |
4267 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 4242 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
4268 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); | 4243 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); |
4269 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4244 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
4270 i::PrototypeIterator iter(isolate, self); | 4245 i::PrototypeIterator iter(isolate, self); |
4271 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 4246 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
4272 i::Handle<i::JSReceiver> proto = | 4247 i::Handle<i::JSReceiver> proto = |
4273 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4248 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
4274 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4249 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4275 isolate, self, key_obj, proto, | 4250 isolate, self, key_obj, proto, |
4276 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4251 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4277 Maybe<i::PropertyAttributes> result = | 4252 Maybe<i::PropertyAttributes> result = |
4278 i::JSReceiver::GetPropertyAttributes(&it); | 4253 i::JSReceiver::GetPropertyAttributes(&it); |
4279 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4254 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
4280 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4255 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4281 if (result.FromJust() == i::ABSENT) return Just(None); | 4256 if (result.FromJust() == i::ABSENT) return Just(None); |
4282 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 4257 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
4283 } | 4258 } |
4284 | 4259 |
4285 | 4260 |
4286 Maybe<PropertyAttribute> | 4261 Maybe<PropertyAttribute> |
4287 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { | 4262 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { |
4288 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4263 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4289 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); | 4264 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
4290 } | 4265 } |
4291 | 4266 |
4292 | 4267 |
4293 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, | 4268 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, |
4294 Local<Name> key) { | 4269 Local<Name> key) { |
4295 PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value); | 4270 PREPARE_FOR_EXECUTION(context, Object, GetRealNamedProperty, Value); |
4296 auto self = Utils::OpenHandle(this); | 4271 auto self = Utils::OpenHandle(this); |
4297 auto key_obj = Utils::OpenHandle(*key); | 4272 auto key_obj = Utils::OpenHandle(*key); |
4298 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4273 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4299 isolate, self, key_obj, self, | 4274 isolate, self, key_obj, self, |
4300 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4275 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4301 Local<Value> result; | 4276 Local<Value> result; |
4302 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4277 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
4303 RETURN_ON_FAILED_EXECUTION(Value); | 4278 RETURN_ON_FAILED_EXECUTION(Value); |
4304 if (!it.IsFound()) return MaybeLocal<Value>(); | 4279 if (!it.IsFound()) return MaybeLocal<Value>(); |
4305 RETURN_ESCAPED(result); | 4280 RETURN_ESCAPED(result); |
4306 } | 4281 } |
4307 | 4282 |
4308 | 4283 |
4309 Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) { | 4284 Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) { |
4310 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4285 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4311 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); | 4286 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); |
4312 } | 4287 } |
4313 | 4288 |
4314 | 4289 |
4315 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4290 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
4316 Local<Context> context, Local<Name> key) { | 4291 Local<Context> context, Local<Name> key) { |
4317 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4292 PREPARE_FOR_EXECUTION_PRIMITIVE( |
4318 context, "v8::Object::GetRealNamedPropertyAttributes()", | 4293 context, Object, GetRealNamedPropertyAttributes, PropertyAttribute); |
4319 PropertyAttribute); | |
4320 auto self = Utils::OpenHandle(this); | 4294 auto self = Utils::OpenHandle(this); |
4321 auto key_obj = Utils::OpenHandle(*key); | 4295 auto key_obj = Utils::OpenHandle(*key); |
4322 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4296 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4323 isolate, self, key_obj, self, | 4297 isolate, self, key_obj, self, |
4324 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4298 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4325 auto result = i::JSReceiver::GetPropertyAttributes(&it); | 4299 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
4326 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4300 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
4327 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4301 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4328 if (result.FromJust() == i::ABSENT) { | 4302 if (result.FromJust() == i::ABSENT) { |
4329 return Just(static_cast<PropertyAttribute>(i::NONE)); | 4303 return Just(static_cast<PropertyAttribute>(i::NONE)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4371 } | 4345 } |
4372 | 4346 |
4373 bool v8::Object::IsConstructor() { | 4347 bool v8::Object::IsConstructor() { |
4374 auto self = Utils::OpenHandle(this); | 4348 auto self = Utils::OpenHandle(this); |
4375 return self->IsConstructor(); | 4349 return self->IsConstructor(); |
4376 } | 4350 } |
4377 | 4351 |
4378 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4352 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
4379 Local<Value> recv, int argc, | 4353 Local<Value> recv, int argc, |
4380 Local<Value> argv[]) { | 4354 Local<Value> argv[]) { |
4381 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4355 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsFunction, Value); |
4382 Value); | |
4383 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 4356 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4384 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4357 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4385 TRACE_EVENT0("v8", "V8.Execute"); | 4358 TRACE_EVENT0("v8", "V8.Execute"); |
4386 auto self = Utils::OpenHandle(this); | 4359 auto self = Utils::OpenHandle(this); |
4387 auto recv_obj = Utils::OpenHandle(*recv); | 4360 auto recv_obj = Utils::OpenHandle(*recv); |
4388 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4361 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4389 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4362 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4390 Local<Value> result; | 4363 Local<Value> result; |
4391 has_pending_exception = !ToLocal<Value>( | 4364 has_pending_exception = !ToLocal<Value>( |
4392 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4365 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
4393 RETURN_ON_FAILED_EXECUTION(Value); | 4366 RETURN_ON_FAILED_EXECUTION(Value); |
4394 RETURN_ESCAPED(result); | 4367 RETURN_ESCAPED(result); |
4395 } | 4368 } |
4396 | 4369 |
4397 | 4370 |
4398 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, | 4371 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
4399 v8::Local<v8::Value> argv[]) { | 4372 v8::Local<v8::Value> argv[]) { |
4400 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4373 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4401 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4374 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
4402 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4375 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
4403 Value); | 4376 Value); |
4404 } | 4377 } |
4405 | 4378 |
4406 | 4379 |
4407 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4380 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
4408 Local<Value> argv[]) { | 4381 Local<Value> argv[]) { |
4409 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4382 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Object, CallAsConstructor, |
4410 "v8::Object::CallAsConstructor()", Value); | 4383 Value); |
4411 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 4384 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4412 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4385 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4413 TRACE_EVENT0("v8", "V8.Execute"); | 4386 TRACE_EVENT0("v8", "V8.Execute"); |
4414 auto self = Utils::OpenHandle(this); | 4387 auto self = Utils::OpenHandle(this); |
4415 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4388 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4416 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4389 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4417 Local<Value> result; | 4390 Local<Value> result; |
4418 has_pending_exception = !ToLocal<Value>( | 4391 has_pending_exception = !ToLocal<Value>( |
4419 i::Execution::New(isolate, self, self, argc, args), &result); | 4392 i::Execution::New(isolate, self, self, argc, args), &result); |
4420 RETURN_ON_FAILED_EXECUTION(Value); | 4393 RETURN_ON_FAILED_EXECUTION(Value); |
4421 RETURN_ESCAPED(result); | 4394 RETURN_ESCAPED(result); |
4422 } | 4395 } |
4423 | 4396 |
4424 | 4397 |
4425 Local<v8::Value> Object::CallAsConstructor(int argc, | 4398 Local<v8::Value> Object::CallAsConstructor(int argc, |
4426 v8::Local<v8::Value> argv[]) { | 4399 v8::Local<v8::Value> argv[]) { |
4427 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4400 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4428 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4401 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
4429 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4402 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
4430 } | 4403 } |
4431 | 4404 |
4432 | 4405 |
4433 MaybeLocal<Function> Function::New(Local<Context> context, | 4406 MaybeLocal<Function> Function::New(Local<Context> context, |
4434 FunctionCallback callback, Local<Value> data, | 4407 FunctionCallback callback, Local<Value> data, |
4435 int length) { | 4408 int length) { |
4436 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); | 4409 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); |
4437 LOG_API(isolate, "Function::New"); | 4410 LOG_API(isolate, Function, New); |
4438 ENTER_V8(isolate); | 4411 ENTER_V8(isolate); |
4439 return FunctionTemplateNew(isolate, callback, nullptr, data, | 4412 return FunctionTemplateNew(isolate, callback, nullptr, data, |
4440 Local<Signature>(), length, true) | 4413 Local<Signature>(), length, true) |
4441 ->GetFunction(context); | 4414 ->GetFunction(context); |
4442 } | 4415 } |
4443 | 4416 |
4444 | 4417 |
4445 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, | 4418 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, |
4446 Local<Value> data, int length) { | 4419 Local<Value> data, int length) { |
4447 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) | 4420 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) |
4448 .FromMaybe(Local<Function>()); | 4421 .FromMaybe(Local<Function>()); |
4449 } | 4422 } |
4450 | 4423 |
4451 | 4424 |
4452 Local<v8::Object> Function::NewInstance() const { | 4425 Local<v8::Object> Function::NewInstance() const { |
4453 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4426 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
4454 .FromMaybe(Local<Object>()); | 4427 .FromMaybe(Local<Object>()); |
4455 } | 4428 } |
4456 | 4429 |
4457 | 4430 |
4458 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, | 4431 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, |
4459 v8::Local<v8::Value> argv[]) const { | 4432 v8::Local<v8::Value> argv[]) const { |
4460 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", | 4433 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, NewInstance, Object); |
4461 Object); | |
4462 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 4434 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4463 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4435 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4464 TRACE_EVENT0("v8", "V8.Execute"); | 4436 TRACE_EVENT0("v8", "V8.Execute"); |
4465 auto self = Utils::OpenHandle(this); | 4437 auto self = Utils::OpenHandle(this); |
4466 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4438 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4467 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4439 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4468 Local<Object> result; | 4440 Local<Object> result; |
4469 has_pending_exception = !ToLocal<Object>( | 4441 has_pending_exception = !ToLocal<Object>( |
4470 i::Execution::New(isolate, self, self, argc, args), &result); | 4442 i::Execution::New(isolate, self, self, argc, args), &result); |
4471 RETURN_ON_FAILED_EXECUTION(Object); | 4443 RETURN_ON_FAILED_EXECUTION(Object); |
4472 RETURN_ESCAPED(result); | 4444 RETURN_ESCAPED(result); |
4473 } | 4445 } |
4474 | 4446 |
4475 | 4447 |
4476 Local<v8::Object> Function::NewInstance(int argc, | 4448 Local<v8::Object> Function::NewInstance(int argc, |
4477 v8::Local<v8::Value> argv[]) const { | 4449 v8::Local<v8::Value> argv[]) const { |
4478 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4450 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4479 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); | 4451 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); |
4480 } | 4452 } |
4481 | 4453 |
4482 | 4454 |
4483 MaybeLocal<v8::Value> Function::Call(Local<Context> context, | 4455 MaybeLocal<v8::Value> Function::Call(Local<Context> context, |
4484 v8::Local<v8::Value> recv, int argc, | 4456 v8::Local<v8::Value> recv, int argc, |
4485 v8::Local<v8::Value> argv[]) { | 4457 v8::Local<v8::Value> argv[]) { |
4486 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); | 4458 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, Function, Call, Value); |
4487 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 4459 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
4488 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4460 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4489 TRACE_EVENT0("v8", "V8.Execute"); | 4461 TRACE_EVENT0("v8", "V8.Execute"); |
4490 auto self = Utils::OpenHandle(this); | 4462 auto self = Utils::OpenHandle(this); |
4491 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4463 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
4492 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4464 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4493 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4465 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4494 Local<Value> result; | 4466 Local<Value> result; |
4495 has_pending_exception = !ToLocal<Value>( | 4467 has_pending_exception = !ToLocal<Value>( |
4496 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4468 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 } | 5162 } |
5191 return true; | 5163 return true; |
5192 } | 5164 } |
5193 | 5165 |
5194 | 5166 |
5195 int String::WriteUtf8(char* buffer, | 5167 int String::WriteUtf8(char* buffer, |
5196 int capacity, | 5168 int capacity, |
5197 int* nchars_ref, | 5169 int* nchars_ref, |
5198 int options) const { | 5170 int options) const { |
5199 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 5171 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
5200 LOG_API(isolate, "String::WriteUtf8"); | 5172 LOG_API(isolate, String, WriteUtf8); |
5201 ENTER_V8(isolate); | 5173 ENTER_V8(isolate); |
5202 i::Handle<i::String> str = Utils::OpenHandle(this); | 5174 i::Handle<i::String> str = Utils::OpenHandle(this); |
5203 if (options & HINT_MANY_WRITES_EXPECTED) { | 5175 if (options & HINT_MANY_WRITES_EXPECTED) { |
5204 str = i::String::Flatten(str); // Flatten the string for efficiency. | 5176 str = i::String::Flatten(str); // Flatten the string for efficiency. |
5205 } | 5177 } |
5206 const int string_length = str->length(); | 5178 const int string_length = str->length(); |
5207 bool write_null = !(options & NO_NULL_TERMINATION); | 5179 bool write_null = !(options & NO_NULL_TERMINATION); |
5208 bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8); | 5180 bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8); |
5209 int max16BitCodeUnitSize = unibrow::Utf8::kMax16BitCodeUnitSize; | 5181 int max16BitCodeUnitSize = unibrow::Utf8::kMax16BitCodeUnitSize; |
5210 // First check if we can just write the string without checking capacity. | 5182 // First check if we can just write the string without checking capacity. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5243 } | 5215 } |
5244 | 5216 |
5245 | 5217 |
5246 template<typename CharType> | 5218 template<typename CharType> |
5247 static inline int WriteHelper(const String* string, | 5219 static inline int WriteHelper(const String* string, |
5248 CharType* buffer, | 5220 CharType* buffer, |
5249 int start, | 5221 int start, |
5250 int length, | 5222 int length, |
5251 int options) { | 5223 int options) { |
5252 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); | 5224 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); |
5253 LOG_API(isolate, "String::Write"); | 5225 LOG_API(isolate, String, Write); |
5254 ENTER_V8(isolate); | 5226 ENTER_V8(isolate); |
5255 DCHECK(start >= 0 && length >= -1); | 5227 DCHECK(start >= 0 && length >= -1); |
5256 i::Handle<i::String> str = Utils::OpenHandle(string); | 5228 i::Handle<i::String> str = Utils::OpenHandle(string); |
5257 if (options & String::HINT_MANY_WRITES_EXPECTED) { | 5229 if (options & String::HINT_MANY_WRITES_EXPECTED) { |
5258 // Flatten the string for efficiency. This applies whether we are | 5230 // Flatten the string for efficiency. This applies whether we are |
5259 // using StringCharacterStream or Get(i) to access the characters. | 5231 // using StringCharacterStream or Get(i) to access the characters. |
5260 str = i::String::Flatten(str); | 5232 str = i::String::Flatten(str); |
5261 } | 5233 } |
5262 int end = start + length; | 5234 int end = start + length; |
5263 if ((length == -1) || (length > str->length() - start) ) | 5235 if ((length == -1) || (length > str->length() - start) ) |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5617 // Leave V8. | 5589 // Leave V8. |
5618 | 5590 |
5619 return env; | 5591 return env; |
5620 } | 5592 } |
5621 | 5593 |
5622 Local<Context> v8::Context::New(v8::Isolate* external_isolate, | 5594 Local<Context> v8::Context::New(v8::Isolate* external_isolate, |
5623 v8::ExtensionConfiguration* extensions, | 5595 v8::ExtensionConfiguration* extensions, |
5624 v8::Local<ObjectTemplate> global_template, | 5596 v8::Local<ObjectTemplate> global_template, |
5625 v8::Local<Value> global_object) { | 5597 v8::Local<Value> global_object) { |
5626 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 5598 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
5627 LOG_API(isolate, "Context::New"); | 5599 LOG_API(isolate, Context, New); |
5628 i::HandleScope scope(isolate); | 5600 i::HandleScope scope(isolate); |
5629 ExtensionConfiguration no_extensions; | 5601 ExtensionConfiguration no_extensions; |
5630 if (extensions == NULL) extensions = &no_extensions; | 5602 if (extensions == NULL) extensions = &no_extensions; |
5631 i::Handle<i::Context> env = | 5603 i::Handle<i::Context> env = |
5632 CreateEnvironment(isolate, extensions, global_template, global_object); | 5604 CreateEnvironment(isolate, extensions, global_template, global_object); |
5633 if (env.is_null()) { | 5605 if (env.is_null()) { |
5634 if (isolate->has_pending_exception()) { | 5606 if (isolate->has_pending_exception()) { |
5635 isolate->OptionalRescheduleException(true); | 5607 isolate->OptionalRescheduleException(true); |
5636 } | 5608 } |
5637 return Local<Context>(); | 5609 return Local<Context>(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5720 } | 5692 } |
5721 | 5693 |
5722 | 5694 |
5723 size_t Context::EstimatedSize() { | 5695 size_t Context::EstimatedSize() { |
5724 return static_cast<size_t>( | 5696 return static_cast<size_t>( |
5725 i::ContextMeasure(*Utils::OpenHandle(this)).Size()); | 5697 i::ContextMeasure(*Utils::OpenHandle(this)).Size()); |
5726 } | 5698 } |
5727 | 5699 |
5728 | 5700 |
5729 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { | 5701 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { |
5730 PREPARE_FOR_EXECUTION(context, "v8::ObjectTemplate::NewInstance()", Object); | 5702 PREPARE_FOR_EXECUTION(context, ObjectTemplate, NewInstance, Object); |
5731 auto self = Utils::OpenHandle(this); | 5703 auto self = Utils::OpenHandle(this); |
5732 Local<Object> result; | 5704 Local<Object> result; |
5733 has_pending_exception = | 5705 has_pending_exception = |
5734 !ToLocal<Object>(i::ApiNatives::InstantiateObject(self), &result); | 5706 !ToLocal<Object>(i::ApiNatives::InstantiateObject(self), &result); |
5735 RETURN_ON_FAILED_EXECUTION(Object); | 5707 RETURN_ON_FAILED_EXECUTION(Object); |
5736 RETURN_ESCAPED(result); | 5708 RETURN_ESCAPED(result); |
5737 } | 5709 } |
5738 | 5710 |
5739 | 5711 |
5740 Local<v8::Object> ObjectTemplate::NewInstance() { | 5712 Local<v8::Object> ObjectTemplate::NewInstance() { |
5741 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 5713 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
5742 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context), Object); | 5714 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context), Object); |
5743 } | 5715 } |
5744 | 5716 |
5745 | 5717 |
5746 MaybeLocal<v8::Function> FunctionTemplate::GetFunction(Local<Context> context) { | 5718 MaybeLocal<v8::Function> FunctionTemplate::GetFunction(Local<Context> context) { |
5747 PREPARE_FOR_EXECUTION(context, "v8::FunctionTemplate::GetFunction()", | 5719 PREPARE_FOR_EXECUTION(context, FunctionTemplate, GetFunction, Function); |
5748 Function); | |
5749 auto self = Utils::OpenHandle(this); | 5720 auto self = Utils::OpenHandle(this); |
5750 Local<Function> result; | 5721 Local<Function> result; |
5751 has_pending_exception = | 5722 has_pending_exception = |
5752 !ToLocal<Function>(i::ApiNatives::InstantiateFunction(self), &result); | 5723 !ToLocal<Function>(i::ApiNatives::InstantiateFunction(self), &result); |
5753 RETURN_ON_FAILED_EXECUTION(Function); | 5724 RETURN_ON_FAILED_EXECUTION(Function); |
5754 RETURN_ESCAPED(result); | 5725 RETURN_ESCAPED(result); |
5755 } | 5726 } |
5756 | 5727 |
5757 | 5728 |
5758 Local<v8::Function> FunctionTemplate::GetFunction() { | 5729 Local<v8::Function> FunctionTemplate::GetFunction() { |
5759 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 5730 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
5760 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); | 5731 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); |
5761 } | 5732 } |
5762 | 5733 |
5763 | 5734 |
5764 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { | 5735 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { |
5765 auto self = Utils::OpenHandle(this); | 5736 auto self = Utils::OpenHandle(this); |
5766 auto obj = Utils::OpenHandle(*value); | 5737 auto obj = Utils::OpenHandle(*value); |
5767 return self->IsTemplateFor(*obj); | 5738 return self->IsTemplateFor(*obj); |
5768 } | 5739 } |
5769 | 5740 |
5770 | 5741 |
5771 Local<External> v8::External::New(Isolate* isolate, void* value) { | 5742 Local<External> v8::External::New(Isolate* isolate, void* value) { |
5772 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5743 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
5773 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5744 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5774 LOG_API(i_isolate, "External::New"); | 5745 LOG_API(i_isolate, External, New); |
5775 ENTER_V8(i_isolate); | 5746 ENTER_V8(i_isolate); |
5776 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 5747 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
5777 return Utils::ExternalToLocal(external); | 5748 return Utils::ExternalToLocal(external); |
5778 } | 5749 } |
5779 | 5750 |
5780 | 5751 |
5781 void* External::Value() const { | 5752 void* External::Value() const { |
5782 return ExternalValue(*Utils::OpenHandle(this)); | 5753 return ExternalValue(*Utils::OpenHandle(this)); |
5783 } | 5754 } |
5784 | 5755 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5832 i::Vector<const uint16_t> string) { | 5803 i::Vector<const uint16_t> string) { |
5833 if (type == v8::NewStringType::kInternalized) { | 5804 if (type == v8::NewStringType::kInternalized) { |
5834 return factory->InternalizeTwoByteString(string); | 5805 return factory->InternalizeTwoByteString(string); |
5835 } | 5806 } |
5836 return factory->NewStringFromTwoByte(string); | 5807 return factory->NewStringFromTwoByte(string); |
5837 } | 5808 } |
5838 | 5809 |
5839 | 5810 |
5840 STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength); | 5811 STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength); |
5841 | 5812 |
5842 | |
5843 template <typename Char> | |
5844 inline MaybeLocal<String> NewString(Isolate* v8_isolate, const char* location, | |
5845 const char* env, const Char* data, | |
5846 v8::NewStringType type, int length) { | |
5847 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | |
5848 if (length == 0) return String::Empty(v8_isolate); | |
5849 // TODO(dcarney): throw a context free exception. | |
5850 if (length > i::String::kMaxLength) return MaybeLocal<String>(); | |
5851 ENTER_V8(isolate); | |
5852 LOG_API(isolate, env); | |
5853 if (length < 0) length = StringLength(data); | |
5854 i::Handle<i::String> result = | |
5855 NewString(isolate->factory(), type, i::Vector<const Char>(data, length)) | |
5856 .ToHandleChecked(); | |
5857 return Utils::ToLocal(result); | |
5858 } | |
5859 | |
5860 } // anonymous namespace | 5813 } // anonymous namespace |
5861 | 5814 |
| 5815 // TODO(dcarney): throw a context free exception. |
| 5816 #define NEW_STRING(isolate, class_name, function_name, Char, data, type, \ |
| 5817 length) \ |
| 5818 MaybeLocal<String> result; \ |
| 5819 if (length == 0) { \ |
| 5820 result = String::Empty(isolate); \ |
| 5821 } else if (length > i::String::kMaxLength) { \ |
| 5822 result = MaybeLocal<String>(); \ |
| 5823 } else { \ |
| 5824 i::Isolate* i_isolate = reinterpret_cast<internal::Isolate*>(isolate); \ |
| 5825 ENTER_V8(i_isolate); \ |
| 5826 LOG_API(i_isolate, class_name, function_name); \ |
| 5827 if (length < 0) length = StringLength(data); \ |
| 5828 i::Handle<i::String> handle_result = \ |
| 5829 NewString(i_isolate->factory(), type, \ |
| 5830 i::Vector<const Char>(data, length)) \ |
| 5831 .ToHandleChecked(); \ |
| 5832 result = Utils::ToLocal(handle_result); \ |
| 5833 } |
5862 | 5834 |
5863 Local<String> String::NewFromUtf8(Isolate* isolate, | 5835 Local<String> String::NewFromUtf8(Isolate* isolate, |
5864 const char* data, | 5836 const char* data, |
5865 NewStringType type, | 5837 NewStringType type, |
5866 int length) { | 5838 int length) { |
5867 RETURN_TO_LOCAL_UNCHECKED( | 5839 NEW_STRING(isolate, String, NewFromUtf8, char, data, |
5868 NewString(isolate, "v8::String::NewFromUtf8()", "String::NewFromUtf8", | 5840 static_cast<v8::NewStringType>(type), length); |
5869 data, static_cast<v8::NewStringType>(type), length), | 5841 RETURN_TO_LOCAL_UNCHECKED(result, String); |
5870 String); | |
5871 } | 5842 } |
5872 | 5843 |
5873 | 5844 |
5874 MaybeLocal<String> String::NewFromUtf8(Isolate* isolate, const char* data, | 5845 MaybeLocal<String> String::NewFromUtf8(Isolate* isolate, const char* data, |
5875 v8::NewStringType type, int length) { | 5846 v8::NewStringType type, int length) { |
5876 return NewString(isolate, "v8::String::NewFromUtf8()", "String::NewFromUtf8", | 5847 NEW_STRING(isolate, String, NewFromUtf8, char, data, type, length); |
5877 data, type, length); | 5848 return result; |
5878 } | 5849 } |
5879 | 5850 |
5880 | 5851 |
5881 Local<String> String::NewFromOneByte(Isolate* isolate, | 5852 Local<String> String::NewFromOneByte(Isolate* isolate, |
5882 const uint8_t* data, | 5853 const uint8_t* data, |
5883 NewStringType type, | 5854 NewStringType type, |
5884 int length) { | 5855 int length) { |
5885 RETURN_TO_LOCAL_UNCHECKED( | 5856 NEW_STRING(isolate, String, NewFromOneByte, uint8_t, data, |
5886 NewString(isolate, "v8::String::NewFromOneByte()", | 5857 static_cast<v8::NewStringType>(type), length); |
5887 "String::NewFromOneByte", data, | 5858 RETURN_TO_LOCAL_UNCHECKED(result, String); |
5888 static_cast<v8::NewStringType>(type), length), | |
5889 String); | |
5890 } | 5859 } |
5891 | 5860 |
5892 | 5861 |
5893 MaybeLocal<String> String::NewFromOneByte(Isolate* isolate, const uint8_t* data, | 5862 MaybeLocal<String> String::NewFromOneByte(Isolate* isolate, const uint8_t* data, |
5894 v8::NewStringType type, int length) { | 5863 v8::NewStringType type, int length) { |
5895 return NewString(isolate, "v8::String::NewFromOneByte()", | 5864 NEW_STRING(isolate, String, NewFromOneByte, uint8_t, data, type, length); |
5896 "String::NewFromOneByte", data, type, length); | 5865 return result; |
5897 } | 5866 } |
5898 | 5867 |
5899 | 5868 |
5900 Local<String> String::NewFromTwoByte(Isolate* isolate, | 5869 Local<String> String::NewFromTwoByte(Isolate* isolate, |
5901 const uint16_t* data, | 5870 const uint16_t* data, |
5902 NewStringType type, | 5871 NewStringType type, |
5903 int length) { | 5872 int length) { |
5904 RETURN_TO_LOCAL_UNCHECKED( | 5873 NEW_STRING(isolate, String, NewFromTwoByte, uint16_t, data, |
5905 NewString(isolate, "v8::String::NewFromTwoByte()", | 5874 static_cast<v8::NewStringType>(type), length); |
5906 "String::NewFromTwoByte", data, | 5875 RETURN_TO_LOCAL_UNCHECKED(result, String); |
5907 static_cast<v8::NewStringType>(type), length), | |
5908 String); | |
5909 } | 5876 } |
5910 | 5877 |
5911 | 5878 |
5912 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, | 5879 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, |
5913 const uint16_t* data, | 5880 const uint16_t* data, |
5914 v8::NewStringType type, int length) { | 5881 v8::NewStringType type, int length) { |
5915 return NewString(isolate, "v8::String::NewFromTwoByte()", | 5882 NEW_STRING(isolate, String, NewFromTwoByte, uint16_t, data, type, length); |
5916 "String::NewFromTwoByte", data, type, length); | 5883 return result; |
5917 } | 5884 } |
5918 | 5885 |
5919 | 5886 |
5920 Local<String> v8::String::Concat(Local<String> left, Local<String> right) { | 5887 Local<String> v8::String::Concat(Local<String> left, Local<String> right) { |
5921 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5888 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
5922 i::Isolate* isolate = left_string->GetIsolate(); | 5889 i::Isolate* isolate = left_string->GetIsolate(); |
5923 ENTER_V8(isolate); | 5890 ENTER_V8(isolate); |
5924 LOG_API(isolate, "v8::String::Concat"); | 5891 LOG_API(isolate, String, Concat); |
5925 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5892 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5926 // If we are steering towards a range error, do not wait for the error to be | 5893 // If we are steering towards a range error, do not wait for the error to be |
5927 // thrown, and return the null handle instead. | 5894 // thrown, and return the null handle instead. |
5928 if (left_string->length() + right_string->length() > i::String::kMaxLength) { | 5895 if (left_string->length() + right_string->length() > i::String::kMaxLength) { |
5929 return Local<String>(); | 5896 return Local<String>(); |
5930 } | 5897 } |
5931 i::Handle<i::String> result = isolate->factory()->NewConsString( | 5898 i::Handle<i::String> result = isolate->factory()->NewConsString( |
5932 left_string, right_string).ToHandleChecked(); | 5899 left_string, right_string).ToHandleChecked(); |
5933 return Utils::ToLocal(result); | 5900 return Utils::ToLocal(result); |
5934 } | 5901 } |
5935 | 5902 |
5936 | 5903 |
5937 MaybeLocal<String> v8::String::NewExternalTwoByte( | 5904 MaybeLocal<String> v8::String::NewExternalTwoByte( |
5938 Isolate* isolate, v8::String::ExternalStringResource* resource) { | 5905 Isolate* isolate, v8::String::ExternalStringResource* resource) { |
5939 CHECK(resource && resource->data()); | 5906 CHECK(resource && resource->data()); |
5940 // TODO(dcarney): throw a context free exception. | 5907 // TODO(dcarney): throw a context free exception. |
5941 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { | 5908 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { |
5942 return MaybeLocal<String>(); | 5909 return MaybeLocal<String>(); |
5943 } | 5910 } |
5944 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5911 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5945 ENTER_V8(i_isolate); | 5912 ENTER_V8(i_isolate); |
5946 LOG_API(i_isolate, "String::NewExternalTwoByte"); | 5913 LOG_API(i_isolate, String, NewExternalTwoByte); |
5947 i::Handle<i::String> string = i_isolate->factory() | 5914 i::Handle<i::String> string = i_isolate->factory() |
5948 ->NewExternalStringFromTwoByte(resource) | 5915 ->NewExternalStringFromTwoByte(resource) |
5949 .ToHandleChecked(); | 5916 .ToHandleChecked(); |
5950 i_isolate->heap()->RegisterExternalString(*string); | 5917 i_isolate->heap()->RegisterExternalString(*string); |
5951 return Utils::ToLocal(string); | 5918 return Utils::ToLocal(string); |
5952 } | 5919 } |
5953 | 5920 |
5954 | 5921 |
5955 Local<String> v8::String::NewExternal( | 5922 Local<String> v8::String::NewExternal( |
5956 Isolate* isolate, v8::String::ExternalStringResource* resource) { | 5923 Isolate* isolate, v8::String::ExternalStringResource* resource) { |
5957 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String); | 5924 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String); |
5958 } | 5925 } |
5959 | 5926 |
5960 | 5927 |
5961 MaybeLocal<String> v8::String::NewExternalOneByte( | 5928 MaybeLocal<String> v8::String::NewExternalOneByte( |
5962 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { | 5929 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { |
5963 CHECK(resource && resource->data()); | 5930 CHECK(resource && resource->data()); |
5964 // TODO(dcarney): throw a context free exception. | 5931 // TODO(dcarney): throw a context free exception. |
5965 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { | 5932 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { |
5966 return MaybeLocal<String>(); | 5933 return MaybeLocal<String>(); |
5967 } | 5934 } |
5968 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5935 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5969 ENTER_V8(i_isolate); | 5936 ENTER_V8(i_isolate); |
5970 LOG_API(i_isolate, "String::NewExternalOneByte"); | 5937 LOG_API(i_isolate, String, NewExternalOneByte); |
5971 i::Handle<i::String> string = i_isolate->factory() | 5938 i::Handle<i::String> string = i_isolate->factory() |
5972 ->NewExternalStringFromOneByte(resource) | 5939 ->NewExternalStringFromOneByte(resource) |
5973 .ToHandleChecked(); | 5940 .ToHandleChecked(); |
5974 i_isolate->heap()->RegisterExternalString(*string); | 5941 i_isolate->heap()->RegisterExternalString(*string); |
5975 return Utils::ToLocal(string); | 5942 return Utils::ToLocal(string); |
5976 } | 5943 } |
5977 | 5944 |
5978 | 5945 |
5979 Local<String> v8::String::NewExternal( | 5946 Local<String> v8::String::NewExternal( |
5980 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { | 5947 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6043 | 6010 |
6044 | 6011 |
6045 Isolate* v8::Object::GetIsolate() { | 6012 Isolate* v8::Object::GetIsolate() { |
6046 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 6013 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
6047 return reinterpret_cast<Isolate*>(i_isolate); | 6014 return reinterpret_cast<Isolate*>(i_isolate); |
6048 } | 6015 } |
6049 | 6016 |
6050 | 6017 |
6051 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 6018 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
6052 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6019 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6053 LOG_API(i_isolate, "Object::New"); | 6020 LOG_API(i_isolate, Object, New); |
6054 ENTER_V8(i_isolate); | 6021 ENTER_V8(i_isolate); |
6055 i::Handle<i::JSObject> obj = | 6022 i::Handle<i::JSObject> obj = |
6056 i_isolate->factory()->NewJSObject(i_isolate->object_function()); | 6023 i_isolate->factory()->NewJSObject(i_isolate->object_function()); |
6057 return Utils::ToLocal(obj); | 6024 return Utils::ToLocal(obj); |
6058 } | 6025 } |
6059 | 6026 |
6060 | 6027 |
6061 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { | 6028 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { |
6062 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6029 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6063 LOG_API(i_isolate, "NumberObject::New"); | 6030 LOG_API(i_isolate, NumberObject, New); |
6064 ENTER_V8(i_isolate); | 6031 ENTER_V8(i_isolate); |
6065 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); | 6032 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
6066 i::Handle<i::Object> obj = | 6033 i::Handle<i::Object> obj = |
6067 i::Object::ToObject(i_isolate, number).ToHandleChecked(); | 6034 i::Object::ToObject(i_isolate, number).ToHandleChecked(); |
6068 return Utils::ToLocal(obj); | 6035 return Utils::ToLocal(obj); |
6069 } | 6036 } |
6070 | 6037 |
6071 | 6038 |
6072 double v8::NumberObject::ValueOf() const { | 6039 double v8::NumberObject::ValueOf() const { |
6073 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6040 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6074 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6041 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
6075 i::Isolate* isolate = jsvalue->GetIsolate(); | 6042 i::Isolate* isolate = jsvalue->GetIsolate(); |
6076 LOG_API(isolate, "NumberObject::NumberValue"); | 6043 LOG_API(isolate, NumberObject, NumberValue); |
6077 return jsvalue->value()->Number(); | 6044 return jsvalue->value()->Number(); |
6078 } | 6045 } |
6079 | 6046 |
6080 | 6047 |
6081 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) { | 6048 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) { |
6082 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6049 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6083 LOG_API(i_isolate, "BooleanObject::New"); | 6050 LOG_API(i_isolate, BooleanObject, New); |
6084 ENTER_V8(i_isolate); | 6051 ENTER_V8(i_isolate); |
6085 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value() | 6052 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value() |
6086 : i_isolate->heap()->false_value(), | 6053 : i_isolate->heap()->false_value(), |
6087 i_isolate); | 6054 i_isolate); |
6088 i::Handle<i::Object> obj = | 6055 i::Handle<i::Object> obj = |
6089 i::Object::ToObject(i_isolate, boolean).ToHandleChecked(); | 6056 i::Object::ToObject(i_isolate, boolean).ToHandleChecked(); |
6090 return Utils::ToLocal(obj); | 6057 return Utils::ToLocal(obj); |
6091 } | 6058 } |
6092 | 6059 |
6093 | 6060 |
6094 Local<v8::Value> v8::BooleanObject::New(bool value) { | 6061 Local<v8::Value> v8::BooleanObject::New(bool value) { |
6095 return New(Isolate::GetCurrent(), value); | 6062 return New(Isolate::GetCurrent(), value); |
6096 } | 6063 } |
6097 | 6064 |
6098 | 6065 |
6099 bool v8::BooleanObject::ValueOf() const { | 6066 bool v8::BooleanObject::ValueOf() const { |
6100 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6067 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6101 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6068 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
6102 i::Isolate* isolate = jsvalue->GetIsolate(); | 6069 i::Isolate* isolate = jsvalue->GetIsolate(); |
6103 LOG_API(isolate, "BooleanObject::BooleanValue"); | 6070 LOG_API(isolate, BooleanObject, BooleanValue); |
6104 return jsvalue->value()->IsTrue(); | 6071 return jsvalue->value()->IsTrue(); |
6105 } | 6072 } |
6106 | 6073 |
6107 | 6074 |
6108 Local<v8::Value> v8::StringObject::New(Local<String> value) { | 6075 Local<v8::Value> v8::StringObject::New(Local<String> value) { |
6109 i::Handle<i::String> string = Utils::OpenHandle(*value); | 6076 i::Handle<i::String> string = Utils::OpenHandle(*value); |
6110 i::Isolate* isolate = string->GetIsolate(); | 6077 i::Isolate* isolate = string->GetIsolate(); |
6111 LOG_API(isolate, "StringObject::New"); | 6078 LOG_API(isolate, StringObject, New); |
6112 ENTER_V8(isolate); | 6079 ENTER_V8(isolate); |
6113 i::Handle<i::Object> obj = | 6080 i::Handle<i::Object> obj = |
6114 i::Object::ToObject(isolate, string).ToHandleChecked(); | 6081 i::Object::ToObject(isolate, string).ToHandleChecked(); |
6115 return Utils::ToLocal(obj); | 6082 return Utils::ToLocal(obj); |
6116 } | 6083 } |
6117 | 6084 |
6118 | 6085 |
6119 Local<v8::String> v8::StringObject::ValueOf() const { | 6086 Local<v8::String> v8::StringObject::ValueOf() const { |
6120 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6087 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6121 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6088 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
6122 i::Isolate* isolate = jsvalue->GetIsolate(); | 6089 i::Isolate* isolate = jsvalue->GetIsolate(); |
6123 LOG_API(isolate, "StringObject::StringValue"); | 6090 LOG_API(isolate, StringObject, StringValue); |
6124 return Utils::ToLocal( | 6091 return Utils::ToLocal( |
6125 i::Handle<i::String>(i::String::cast(jsvalue->value()))); | 6092 i::Handle<i::String>(i::String::cast(jsvalue->value()))); |
6126 } | 6093 } |
6127 | 6094 |
6128 | 6095 |
6129 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { | 6096 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { |
6130 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6097 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6131 LOG_API(i_isolate, "SymbolObject::New"); | 6098 LOG_API(i_isolate, SymbolObject, New); |
6132 ENTER_V8(i_isolate); | 6099 ENTER_V8(i_isolate); |
6133 i::Handle<i::Object> obj = i::Object::ToObject( | 6100 i::Handle<i::Object> obj = i::Object::ToObject( |
6134 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); | 6101 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); |
6135 return Utils::ToLocal(obj); | 6102 return Utils::ToLocal(obj); |
6136 } | 6103 } |
6137 | 6104 |
6138 | 6105 |
6139 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 6106 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
6140 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6107 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6141 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6108 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
6142 i::Isolate* isolate = jsvalue->GetIsolate(); | 6109 i::Isolate* isolate = jsvalue->GetIsolate(); |
6143 LOG_API(isolate, "SymbolObject::SymbolValue"); | 6110 LOG_API(isolate, SymbolObject, SymbolValue); |
6144 return Utils::ToLocal( | 6111 return Utils::ToLocal( |
6145 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 6112 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
6146 } | 6113 } |
6147 | 6114 |
6148 | 6115 |
6149 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { | 6116 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { |
6150 if (std::isnan(time)) { | 6117 if (std::isnan(time)) { |
6151 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 6118 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
6152 time = std::numeric_limits<double>::quiet_NaN(); | 6119 time = std::numeric_limits<double>::quiet_NaN(); |
6153 } | 6120 } |
6154 PREPARE_FOR_EXECUTION(context, "Date::New", Value); | 6121 PREPARE_FOR_EXECUTION(context, Date, New, Value); |
6155 Local<Value> result; | 6122 Local<Value> result; |
6156 has_pending_exception = !ToLocal<Value>( | 6123 has_pending_exception = !ToLocal<Value>( |
6157 i::JSDate::New(isolate->date_function(), isolate->date_function(), time), | 6124 i::JSDate::New(isolate->date_function(), isolate->date_function(), time), |
6158 &result); | 6125 &result); |
6159 RETURN_ON_FAILED_EXECUTION(Value); | 6126 RETURN_ON_FAILED_EXECUTION(Value); |
6160 RETURN_ESCAPED(result); | 6127 RETURN_ESCAPED(result); |
6161 } | 6128 } |
6162 | 6129 |
6163 | 6130 |
6164 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { | 6131 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { |
6165 auto context = isolate->GetCurrentContext(); | 6132 auto context = isolate->GetCurrentContext(); |
6166 RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value); | 6133 RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value); |
6167 } | 6134 } |
6168 | 6135 |
6169 | 6136 |
6170 double v8::Date::ValueOf() const { | 6137 double v8::Date::ValueOf() const { |
6171 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6138 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
6172 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 6139 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
6173 i::Isolate* isolate = jsdate->GetIsolate(); | 6140 i::Isolate* isolate = jsdate->GetIsolate(); |
6174 LOG_API(isolate, "Date::NumberValue"); | 6141 LOG_API(isolate, Date, NumberValue); |
6175 return jsdate->value()->Number(); | 6142 return jsdate->value()->Number(); |
6176 } | 6143 } |
6177 | 6144 |
6178 | 6145 |
6179 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { | 6146 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
6180 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6147 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6181 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); | 6148 LOG_API(i_isolate, Date, DateTimeConfigurationChangeNotification); |
6182 ENTER_V8(i_isolate); | 6149 ENTER_V8(i_isolate); |
6183 i_isolate->date_cache()->ResetDateCache(); | 6150 i_isolate->date_cache()->ResetDateCache(); |
6184 if (!i_isolate->eternal_handles()->Exists( | 6151 if (!i_isolate->eternal_handles()->Exists( |
6185 i::EternalHandles::DATE_CACHE_VERSION)) { | 6152 i::EternalHandles::DATE_CACHE_VERSION)) { |
6186 return; | 6153 return; |
6187 } | 6154 } |
6188 i::Handle<i::FixedArray> date_cache_version = | 6155 i::Handle<i::FixedArray> date_cache_version = |
6189 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( | 6156 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( |
6190 i::EternalHandles::DATE_CACHE_VERSION)); | 6157 i::EternalHandles::DATE_CACHE_VERSION)); |
6191 DCHECK_EQ(1, date_cache_version->length()); | 6158 DCHECK_EQ(1, date_cache_version->length()); |
6192 CHECK(date_cache_version->get(0)->IsSmi()); | 6159 CHECK(date_cache_version->get(0)->IsSmi()); |
6193 date_cache_version->set( | 6160 date_cache_version->set( |
6194 0, | 6161 0, |
6195 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); | 6162 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); |
6196 } | 6163 } |
6197 | 6164 |
6198 | 6165 |
6199 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, | 6166 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, |
6200 Local<String> pattern, Flags flags) { | 6167 Local<String> pattern, Flags flags) { |
6201 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); | 6168 PREPARE_FOR_EXECUTION(context, RegExp, New, RegExp); |
6202 Local<v8::RegExp> result; | 6169 Local<v8::RegExp> result; |
6203 has_pending_exception = | 6170 has_pending_exception = |
6204 !ToLocal<RegExp>(i::JSRegExp::New(Utils::OpenHandle(*pattern), | 6171 !ToLocal<RegExp>(i::JSRegExp::New(Utils::OpenHandle(*pattern), |
6205 static_cast<i::JSRegExp::Flags>(flags)), | 6172 static_cast<i::JSRegExp::Flags>(flags)), |
6206 &result); | 6173 &result); |
6207 RETURN_ON_FAILED_EXECUTION(RegExp); | 6174 RETURN_ON_FAILED_EXECUTION(RegExp); |
6208 RETURN_ESCAPED(result); | 6175 RETURN_ESCAPED(result); |
6209 } | 6176 } |
6210 | 6177 |
6211 | 6178 |
(...skipping 24 matching lines...) Expand all Loading... |
6236 #undef REGEXP_FLAG_ASSERT_EQ | 6203 #undef REGEXP_FLAG_ASSERT_EQ |
6237 | 6204 |
6238 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 6205 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
6239 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6206 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
6240 return RegExp::Flags(static_cast<int>(obj->GetFlags())); | 6207 return RegExp::Flags(static_cast<int>(obj->GetFlags())); |
6241 } | 6208 } |
6242 | 6209 |
6243 | 6210 |
6244 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { | 6211 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { |
6245 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6212 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6246 LOG_API(i_isolate, "Array::New"); | 6213 LOG_API(i_isolate, Array, New); |
6247 ENTER_V8(i_isolate); | 6214 ENTER_V8(i_isolate); |
6248 int real_length = length > 0 ? length : 0; | 6215 int real_length = length > 0 ? length : 0; |
6249 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); | 6216 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
6250 i::Handle<i::Object> length_obj = | 6217 i::Handle<i::Object> length_obj = |
6251 i_isolate->factory()->NewNumberFromInt(real_length); | 6218 i_isolate->factory()->NewNumberFromInt(real_length); |
6252 obj->set_length(*length_obj); | 6219 obj->set_length(*length_obj); |
6253 return Utils::ToLocal(obj); | 6220 return Utils::ToLocal(obj); |
6254 } | 6221 } |
6255 | 6222 |
6256 | 6223 |
6257 uint32_t v8::Array::Length() const { | 6224 uint32_t v8::Array::Length() const { |
6258 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 6225 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
6259 i::Object* length = obj->length(); | 6226 i::Object* length = obj->length(); |
6260 if (length->IsSmi()) { | 6227 if (length->IsSmi()) { |
6261 return i::Smi::cast(length)->value(); | 6228 return i::Smi::cast(length)->value(); |
6262 } else { | 6229 } else { |
6263 return static_cast<uint32_t>(length->Number()); | 6230 return static_cast<uint32_t>(length->Number()); |
6264 } | 6231 } |
6265 } | 6232 } |
6266 | 6233 |
6267 | 6234 |
6268 MaybeLocal<Object> Array::CloneElementAt(Local<Context> context, | 6235 MaybeLocal<Object> Array::CloneElementAt(Local<Context> context, |
6269 uint32_t index) { | 6236 uint32_t index) { |
6270 PREPARE_FOR_EXECUTION(context, "v8::Array::CloneElementAt()", Object); | 6237 PREPARE_FOR_EXECUTION(context, Array, CloneElementAt, Object); |
6271 auto self = Utils::OpenHandle(this); | 6238 auto self = Utils::OpenHandle(this); |
6272 if (!self->HasFastObjectElements()) return Local<Object>(); | 6239 if (!self->HasFastObjectElements()) return Local<Object>(); |
6273 i::FixedArray* elms = i::FixedArray::cast(self->elements()); | 6240 i::FixedArray* elms = i::FixedArray::cast(self->elements()); |
6274 i::Object* paragon = elms->get(index); | 6241 i::Object* paragon = elms->get(index); |
6275 if (!paragon->IsJSObject()) return Local<Object>(); | 6242 if (!paragon->IsJSObject()) return Local<Object>(); |
6276 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); | 6243 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); |
6277 Local<Object> result; | 6244 Local<Object> result; |
6278 has_pending_exception = | 6245 has_pending_exception = |
6279 !ToLocal<Object>(isolate->factory()->CopyJSObject(paragon_handle), | 6246 !ToLocal<Object>(isolate->factory()->CopyJSObject(paragon_handle), |
6280 &result); | 6247 &result); |
6281 RETURN_ON_FAILED_EXECUTION(Object); | 6248 RETURN_ON_FAILED_EXECUTION(Object); |
6282 RETURN_ESCAPED(result); | 6249 RETURN_ESCAPED(result); |
6283 } | 6250 } |
6284 | 6251 |
6285 | 6252 |
6286 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); } | 6253 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); } |
6287 | 6254 |
6288 | 6255 |
6289 Local<v8::Map> v8::Map::New(Isolate* isolate) { | 6256 Local<v8::Map> v8::Map::New(Isolate* isolate) { |
6290 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6257 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6291 LOG_API(i_isolate, "Map::New"); | 6258 LOG_API(i_isolate, Map, New); |
6292 ENTER_V8(i_isolate); | 6259 ENTER_V8(i_isolate); |
6293 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap(); | 6260 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap(); |
6294 return Utils::ToLocal(obj); | 6261 return Utils::ToLocal(obj); |
6295 } | 6262 } |
6296 | 6263 |
6297 | 6264 |
6298 size_t v8::Map::Size() const { | 6265 size_t v8::Map::Size() const { |
6299 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); | 6266 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); |
6300 return i::OrderedHashMap::cast(obj->table())->NumberOfElements(); | 6267 return i::OrderedHashMap::cast(obj->table())->NumberOfElements(); |
6301 } | 6268 } |
6302 | 6269 |
6303 | 6270 |
6304 void Map::Clear() { | 6271 void Map::Clear() { |
6305 auto self = Utils::OpenHandle(this); | 6272 auto self = Utils::OpenHandle(this); |
6306 i::Isolate* isolate = self->GetIsolate(); | 6273 i::Isolate* isolate = self->GetIsolate(); |
6307 LOG_API(isolate, "Map::Clear"); | 6274 LOG_API(isolate, Map, Clear); |
6308 ENTER_V8(isolate); | 6275 ENTER_V8(isolate); |
6309 i::JSMap::Clear(self); | 6276 i::JSMap::Clear(self); |
6310 } | 6277 } |
6311 | 6278 |
6312 | 6279 |
6313 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) { | 6280 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) { |
6314 PREPARE_FOR_EXECUTION(context, "Map::Get", Value); | 6281 PREPARE_FOR_EXECUTION(context, Map, Get, Value); |
6315 auto self = Utils::OpenHandle(this); | 6282 auto self = Utils::OpenHandle(this); |
6316 Local<Value> result; | 6283 Local<Value> result; |
6317 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6284 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6318 has_pending_exception = | 6285 has_pending_exception = |
6319 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self, | 6286 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self, |
6320 arraysize(argv), argv), | 6287 arraysize(argv), argv), |
6321 &result); | 6288 &result); |
6322 RETURN_ON_FAILED_EXECUTION(Value); | 6289 RETURN_ON_FAILED_EXECUTION(Value); |
6323 RETURN_ESCAPED(result); | 6290 RETURN_ESCAPED(result); |
6324 } | 6291 } |
6325 | 6292 |
6326 | 6293 |
6327 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key, | 6294 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key, |
6328 Local<Value> value) { | 6295 Local<Value> value) { |
6329 PREPARE_FOR_EXECUTION(context, "Map::Set", Map); | 6296 PREPARE_FOR_EXECUTION(context, Map, Set, Map); |
6330 auto self = Utils::OpenHandle(this); | 6297 auto self = Utils::OpenHandle(this); |
6331 i::Handle<i::Object> result; | 6298 i::Handle<i::Object> result; |
6332 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), | 6299 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), |
6333 Utils::OpenHandle(*value)}; | 6300 Utils::OpenHandle(*value)}; |
6334 has_pending_exception = !i::Execution::Call(isolate, isolate->map_set(), self, | 6301 has_pending_exception = !i::Execution::Call(isolate, isolate->map_set(), self, |
6335 arraysize(argv), argv) | 6302 arraysize(argv), argv) |
6336 .ToHandle(&result); | 6303 .ToHandle(&result); |
6337 RETURN_ON_FAILED_EXECUTION(Map); | 6304 RETURN_ON_FAILED_EXECUTION(Map); |
6338 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); | 6305 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); |
6339 } | 6306 } |
6340 | 6307 |
6341 | 6308 |
6342 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) { | 6309 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) { |
6343 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Has", bool); | 6310 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map, Has, bool); |
6344 auto self = Utils::OpenHandle(this); | 6311 auto self = Utils::OpenHandle(this); |
6345 i::Handle<i::Object> result; | 6312 i::Handle<i::Object> result; |
6346 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6313 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6347 has_pending_exception = !i::Execution::Call(isolate, isolate->map_has(), self, | 6314 has_pending_exception = !i::Execution::Call(isolate, isolate->map_has(), self, |
6348 arraysize(argv), argv) | 6315 arraysize(argv), argv) |
6349 .ToHandle(&result); | 6316 .ToHandle(&result); |
6350 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6317 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6351 return Just(result->IsTrue()); | 6318 return Just(result->IsTrue()); |
6352 } | 6319 } |
6353 | 6320 |
6354 | 6321 |
6355 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) { | 6322 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) { |
6356 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Delete", bool); | 6323 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map, Delete, bool); |
6357 auto self = Utils::OpenHandle(this); | 6324 auto self = Utils::OpenHandle(this); |
6358 i::Handle<i::Object> result; | 6325 i::Handle<i::Object> result; |
6359 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6326 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6360 has_pending_exception = !i::Execution::Call(isolate, isolate->map_delete(), | 6327 has_pending_exception = !i::Execution::Call(isolate, isolate->map_delete(), |
6361 self, arraysize(argv), argv) | 6328 self, arraysize(argv), argv) |
6362 .ToHandle(&result); | 6329 .ToHandle(&result); |
6363 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6330 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6364 return Just(result->IsTrue()); | 6331 return Just(result->IsTrue()); |
6365 } | 6332 } |
6366 | 6333 |
6367 | 6334 |
6368 Local<Array> Map::AsArray() const { | 6335 Local<Array> Map::AsArray() const { |
6369 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); | 6336 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); |
6370 i::Isolate* isolate = obj->GetIsolate(); | 6337 i::Isolate* isolate = obj->GetIsolate(); |
6371 i::Factory* factory = isolate->factory(); | 6338 i::Factory* factory = isolate->factory(); |
6372 LOG_API(isolate, "Map::AsArray"); | 6339 LOG_API(isolate, Map, AsArray); |
6373 ENTER_V8(isolate); | 6340 ENTER_V8(isolate); |
6374 i::Handle<i::OrderedHashMap> table(i::OrderedHashMap::cast(obj->table())); | 6341 i::Handle<i::OrderedHashMap> table(i::OrderedHashMap::cast(obj->table())); |
6375 int length = table->NumberOfElements() * 2; | 6342 int length = table->NumberOfElements() * 2; |
6376 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); | 6343 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); |
6377 int result_index = 0; | 6344 int result_index = 0; |
6378 { | 6345 { |
6379 i::DisallowHeapAllocation no_gc; | 6346 i::DisallowHeapAllocation no_gc; |
6380 int capacity = table->UsedCapacity(); | 6347 int capacity = table->UsedCapacity(); |
6381 i::Oddball* the_hole = isolate->heap()->the_hole_value(); | 6348 i::Oddball* the_hole = isolate->heap()->the_hole_value(); |
6382 for (int i = 0; i < capacity; ++i) { | 6349 for (int i = 0; i < capacity; ++i) { |
6383 i::Object* key = table->KeyAt(i); | 6350 i::Object* key = table->KeyAt(i); |
6384 if (key == the_hole) continue; | 6351 if (key == the_hole) continue; |
6385 result->set(result_index++, key); | 6352 result->set(result_index++, key); |
6386 result->set(result_index++, table->ValueAt(i)); | 6353 result->set(result_index++, table->ValueAt(i)); |
6387 } | 6354 } |
6388 } | 6355 } |
6389 DCHECK_EQ(result_index, result->length()); | 6356 DCHECK_EQ(result_index, result->length()); |
6390 DCHECK_EQ(result_index, length); | 6357 DCHECK_EQ(result_index, length); |
6391 i::Handle<i::JSArray> result_array = | 6358 i::Handle<i::JSArray> result_array = |
6392 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6359 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6393 return Utils::ToLocal(result_array); | 6360 return Utils::ToLocal(result_array); |
6394 } | 6361 } |
6395 | 6362 |
6396 | 6363 |
6397 Local<v8::Set> v8::Set::New(Isolate* isolate) { | 6364 Local<v8::Set> v8::Set::New(Isolate* isolate) { |
6398 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6365 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6399 LOG_API(i_isolate, "Set::New"); | 6366 LOG_API(i_isolate, Set, New); |
6400 ENTER_V8(i_isolate); | 6367 ENTER_V8(i_isolate); |
6401 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); | 6368 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); |
6402 return Utils::ToLocal(obj); | 6369 return Utils::ToLocal(obj); |
6403 } | 6370 } |
6404 | 6371 |
6405 | 6372 |
6406 size_t v8::Set::Size() const { | 6373 size_t v8::Set::Size() const { |
6407 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); | 6374 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); |
6408 return i::OrderedHashSet::cast(obj->table())->NumberOfElements(); | 6375 return i::OrderedHashSet::cast(obj->table())->NumberOfElements(); |
6409 } | 6376 } |
6410 | 6377 |
6411 | 6378 |
6412 void Set::Clear() { | 6379 void Set::Clear() { |
6413 auto self = Utils::OpenHandle(this); | 6380 auto self = Utils::OpenHandle(this); |
6414 i::Isolate* isolate = self->GetIsolate(); | 6381 i::Isolate* isolate = self->GetIsolate(); |
6415 LOG_API(isolate, "Set::Clear"); | 6382 LOG_API(isolate, Set, Clear); |
6416 ENTER_V8(isolate); | 6383 ENTER_V8(isolate); |
6417 i::JSSet::Clear(self); | 6384 i::JSSet::Clear(self); |
6418 } | 6385 } |
6419 | 6386 |
6420 | 6387 |
6421 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) { | 6388 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) { |
6422 PREPARE_FOR_EXECUTION(context, "Set::Add", Set); | 6389 PREPARE_FOR_EXECUTION(context, Set, Add, Set); |
6423 auto self = Utils::OpenHandle(this); | 6390 auto self = Utils::OpenHandle(this); |
6424 i::Handle<i::Object> result; | 6391 i::Handle<i::Object> result; |
6425 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6392 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6426 has_pending_exception = !i::Execution::Call(isolate, isolate->set_add(), self, | 6393 has_pending_exception = !i::Execution::Call(isolate, isolate->set_add(), self, |
6427 arraysize(argv), argv) | 6394 arraysize(argv), argv) |
6428 .ToHandle(&result); | 6395 .ToHandle(&result); |
6429 RETURN_ON_FAILED_EXECUTION(Set); | 6396 RETURN_ON_FAILED_EXECUTION(Set); |
6430 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); | 6397 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); |
6431 } | 6398 } |
6432 | 6399 |
6433 | 6400 |
6434 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) { | 6401 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) { |
6435 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Has", bool); | 6402 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set, Has, bool); |
6436 auto self = Utils::OpenHandle(this); | 6403 auto self = Utils::OpenHandle(this); |
6437 i::Handle<i::Object> result; | 6404 i::Handle<i::Object> result; |
6438 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6405 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6439 has_pending_exception = !i::Execution::Call(isolate, isolate->set_has(), self, | 6406 has_pending_exception = !i::Execution::Call(isolate, isolate->set_has(), self, |
6440 arraysize(argv), argv) | 6407 arraysize(argv), argv) |
6441 .ToHandle(&result); | 6408 .ToHandle(&result); |
6442 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6409 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6443 return Just(result->IsTrue()); | 6410 return Just(result->IsTrue()); |
6444 } | 6411 } |
6445 | 6412 |
6446 | 6413 |
6447 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) { | 6414 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) { |
6448 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Delete", bool); | 6415 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set, Delete, bool); |
6449 auto self = Utils::OpenHandle(this); | 6416 auto self = Utils::OpenHandle(this); |
6450 i::Handle<i::Object> result; | 6417 i::Handle<i::Object> result; |
6451 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6418 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
6452 has_pending_exception = !i::Execution::Call(isolate, isolate->set_delete(), | 6419 has_pending_exception = !i::Execution::Call(isolate, isolate->set_delete(), |
6453 self, arraysize(argv), argv) | 6420 self, arraysize(argv), argv) |
6454 .ToHandle(&result); | 6421 .ToHandle(&result); |
6455 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6422 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6456 return Just(result->IsTrue()); | 6423 return Just(result->IsTrue()); |
6457 } | 6424 } |
6458 | 6425 |
6459 | 6426 |
6460 Local<Array> Set::AsArray() const { | 6427 Local<Array> Set::AsArray() const { |
6461 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); | 6428 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); |
6462 i::Isolate* isolate = obj->GetIsolate(); | 6429 i::Isolate* isolate = obj->GetIsolate(); |
6463 i::Factory* factory = isolate->factory(); | 6430 i::Factory* factory = isolate->factory(); |
6464 LOG_API(isolate, "Set::AsArray"); | 6431 LOG_API(isolate, Set, AsArray); |
6465 ENTER_V8(isolate); | 6432 ENTER_V8(isolate); |
6466 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); | 6433 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); |
6467 int length = table->NumberOfElements(); | 6434 int length = table->NumberOfElements(); |
6468 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); | 6435 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); |
6469 int result_index = 0; | 6436 int result_index = 0; |
6470 { | 6437 { |
6471 i::DisallowHeapAllocation no_gc; | 6438 i::DisallowHeapAllocation no_gc; |
6472 int capacity = table->UsedCapacity(); | 6439 int capacity = table->UsedCapacity(); |
6473 i::Oddball* the_hole = isolate->heap()->the_hole_value(); | 6440 i::Oddball* the_hole = isolate->heap()->the_hole_value(); |
6474 for (int i = 0; i < capacity; ++i) { | 6441 for (int i = 0; i < capacity; ++i) { |
6475 i::Object* key = table->KeyAt(i); | 6442 i::Object* key = table->KeyAt(i); |
6476 if (key == the_hole) continue; | 6443 if (key == the_hole) continue; |
6477 result->set(result_index++, key); | 6444 result->set(result_index++, key); |
6478 } | 6445 } |
6479 } | 6446 } |
6480 DCHECK_EQ(result_index, result->length()); | 6447 DCHECK_EQ(result_index, result->length()); |
6481 DCHECK_EQ(result_index, length); | 6448 DCHECK_EQ(result_index, length); |
6482 i::Handle<i::JSArray> result_array = | 6449 i::Handle<i::JSArray> result_array = |
6483 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6450 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
6484 return Utils::ToLocal(result_array); | 6451 return Utils::ToLocal(result_array); |
6485 } | 6452 } |
6486 | 6453 |
6487 | 6454 |
6488 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6455 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
6489 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6456 PREPARE_FOR_EXECUTION(context, Promise_Resolver, New, Resolver); |
6490 i::Handle<i::Object> result; | 6457 i::Handle<i::Object> result; |
6491 has_pending_exception = | 6458 has_pending_exception = |
6492 !i::Execution::Call(isolate, isolate->promise_create(), | 6459 !i::Execution::Call(isolate, isolate->promise_create(), |
6493 isolate->factory()->undefined_value(), 0, NULL) | 6460 isolate->factory()->undefined_value(), 0, NULL) |
6494 .ToHandle(&result); | 6461 .ToHandle(&result); |
6495 RETURN_ON_FAILED_EXECUTION(Promise::Resolver); | 6462 RETURN_ON_FAILED_EXECUTION(Promise::Resolver); |
6496 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result))); | 6463 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result))); |
6497 } | 6464 } |
6498 | 6465 |
6499 | 6466 |
6500 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { | 6467 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { |
6501 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), | 6468 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), |
6502 Promise::Resolver); | 6469 Promise::Resolver); |
6503 } | 6470 } |
6504 | 6471 |
6505 | 6472 |
6506 Local<Promise> Promise::Resolver::GetPromise() { | 6473 Local<Promise> Promise::Resolver::GetPromise() { |
6507 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); | 6474 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
6508 return Local<Promise>::Cast(Utils::ToLocal(promise)); | 6475 return Local<Promise>::Cast(Utils::ToLocal(promise)); |
6509 } | 6476 } |
6510 | 6477 |
6511 | 6478 |
6512 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, | 6479 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, |
6513 Local<Value> value) { | 6480 Local<Value> value) { |
6514 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6481 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver, Resolve, bool); |
6515 auto self = Utils::OpenHandle(this); | 6482 auto self = Utils::OpenHandle(this); |
6516 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6483 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
6517 has_pending_exception = | 6484 has_pending_exception = |
6518 i::Execution::Call(isolate, isolate->promise_resolve(), | 6485 i::Execution::Call(isolate, isolate->promise_resolve(), |
6519 isolate->factory()->undefined_value(), arraysize(argv), | 6486 isolate->factory()->undefined_value(), arraysize(argv), |
6520 argv) | 6487 argv) |
6521 .is_null(); | 6488 .is_null(); |
6522 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6489 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6523 return Just(true); | 6490 return Just(true); |
6524 } | 6491 } |
6525 | 6492 |
6526 | 6493 |
6527 void Promise::Resolver::Resolve(Local<Value> value) { | 6494 void Promise::Resolver::Resolve(Local<Value> value) { |
6528 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6495 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6529 USE(Resolve(context, value)); | 6496 USE(Resolve(context, value)); |
6530 } | 6497 } |
6531 | 6498 |
6532 | 6499 |
6533 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, | 6500 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, |
6534 Local<Value> value) { | 6501 Local<Value> value) { |
6535 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6502 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver, Resolve, bool); |
6536 auto self = Utils::OpenHandle(this); | 6503 auto self = Utils::OpenHandle(this); |
6537 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6504 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
6538 has_pending_exception = | 6505 has_pending_exception = |
6539 i::Execution::Call(isolate, isolate->promise_reject(), | 6506 i::Execution::Call(isolate, isolate->promise_reject(), |
6540 isolate->factory()->undefined_value(), arraysize(argv), | 6507 isolate->factory()->undefined_value(), arraysize(argv), |
6541 argv) | 6508 argv) |
6542 .is_null(); | 6509 .is_null(); |
6543 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6510 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6544 return Just(true); | 6511 return Just(true); |
6545 } | 6512 } |
6546 | 6513 |
6547 | 6514 |
6548 void Promise::Resolver::Reject(Local<Value> value) { | 6515 void Promise::Resolver::Reject(Local<Value> value) { |
6549 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6516 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6550 USE(Reject(context, value)); | 6517 USE(Reject(context, value)); |
6551 } | 6518 } |
6552 | 6519 |
6553 | 6520 |
6554 namespace { | 6521 namespace { |
6555 | 6522 |
6556 MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, | 6523 MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, |
6557 Local<Function> handler) { | 6524 Local<Function> handler) { |
6558 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); | 6525 PREPARE_FOR_EXECUTION(context, Promise, Chain, Promise); |
6559 auto self = Utils::OpenHandle(value); | 6526 auto self = Utils::OpenHandle(value); |
6560 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; | 6527 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; |
6561 i::Handle<i::Object> result; | 6528 i::Handle<i::Object> result; |
6562 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), | 6529 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), |
6563 self, arraysize(argv), argv) | 6530 self, arraysize(argv), argv) |
6564 .ToHandle(&result); | 6531 .ToHandle(&result); |
6565 RETURN_ON_FAILED_EXECUTION(Promise); | 6532 RETURN_ON_FAILED_EXECUTION(Promise); |
6566 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6533 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6567 } | 6534 } |
6568 | 6535 |
6569 } // namespace | 6536 } // namespace |
6570 | 6537 |
6571 | 6538 |
6572 MaybeLocal<Promise> Promise::Chain(Local<Context> context, | 6539 MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
6573 Local<Function> handler) { | 6540 Local<Function> handler) { |
6574 return DoChain(this, context, handler); | 6541 return DoChain(this, context, handler); |
6575 } | 6542 } |
6576 | 6543 |
6577 | 6544 |
6578 Local<Promise> Promise::Chain(Local<Function> handler) { | 6545 Local<Promise> Promise::Chain(Local<Function> handler) { |
6579 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6546 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6580 RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); | 6547 RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); |
6581 } | 6548 } |
6582 | 6549 |
6583 | 6550 |
6584 MaybeLocal<Promise> Promise::Catch(Local<Context> context, | 6551 MaybeLocal<Promise> Promise::Catch(Local<Context> context, |
6585 Local<Function> handler) { | 6552 Local<Function> handler) { |
6586 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise); | 6553 PREPARE_FOR_EXECUTION(context, Promise, Catch, Promise); |
6587 auto self = Utils::OpenHandle(this); | 6554 auto self = Utils::OpenHandle(this); |
6588 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6555 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
6589 i::Handle<i::Object> result; | 6556 i::Handle<i::Object> result; |
6590 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), | 6557 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), |
6591 self, arraysize(argv), argv) | 6558 self, arraysize(argv), argv) |
6592 .ToHandle(&result); | 6559 .ToHandle(&result); |
6593 RETURN_ON_FAILED_EXECUTION(Promise); | 6560 RETURN_ON_FAILED_EXECUTION(Promise); |
6594 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6561 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6595 } | 6562 } |
6596 | 6563 |
6597 | 6564 |
6598 Local<Promise> Promise::Catch(Local<Function> handler) { | 6565 Local<Promise> Promise::Catch(Local<Function> handler) { |
6599 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6566 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6600 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); | 6567 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); |
6601 } | 6568 } |
6602 | 6569 |
6603 | 6570 |
6604 MaybeLocal<Promise> Promise::Then(Local<Context> context, | 6571 MaybeLocal<Promise> Promise::Then(Local<Context> context, |
6605 Local<Function> handler) { | 6572 Local<Function> handler) { |
6606 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise); | 6573 PREPARE_FOR_EXECUTION(context, Promise, Then, Promise); |
6607 auto self = Utils::OpenHandle(this); | 6574 auto self = Utils::OpenHandle(this); |
6608 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6575 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
6609 i::Handle<i::Object> result; | 6576 i::Handle<i::Object> result; |
6610 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_then(), | 6577 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_then(), |
6611 self, arraysize(argv), argv) | 6578 self, arraysize(argv), argv) |
6612 .ToHandle(&result); | 6579 .ToHandle(&result); |
6613 RETURN_ON_FAILED_EXECUTION(Promise); | 6580 RETURN_ON_FAILED_EXECUTION(Promise); |
6614 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6581 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6615 } | 6582 } |
6616 | 6583 |
6617 | 6584 |
6618 Local<Promise> Promise::Then(Local<Function> handler) { | 6585 Local<Promise> Promise::Then(Local<Function> handler) { |
6619 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6586 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6620 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); | 6587 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); |
6621 } | 6588 } |
6622 | 6589 |
6623 | 6590 |
6624 bool Promise::HasHandler() { | 6591 bool Promise::HasHandler() { |
6625 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); | 6592 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
6626 i::Isolate* isolate = promise->GetIsolate(); | 6593 i::Isolate* isolate = promise->GetIsolate(); |
6627 LOG_API(isolate, "Promise::HasRejectHandler"); | 6594 LOG_API(isolate, Promise, HasRejectHandler); |
6628 ENTER_V8(isolate); | 6595 ENTER_V8(isolate); |
6629 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 6596 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); |
6630 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); | 6597 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); |
6631 } | 6598 } |
6632 | 6599 |
6633 | 6600 |
6634 Local<Object> Proxy::GetTarget() { | 6601 Local<Object> Proxy::GetTarget() { |
6635 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); | 6602 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); |
6636 i::Handle<i::JSReceiver> target(self->target()); | 6603 i::Handle<i::JSReceiver> target(self->target()); |
6637 return Utils::ToLocal(target); | 6604 return Utils::ToLocal(target); |
(...skipping 14 matching lines...) Expand all Loading... |
6652 | 6619 |
6653 | 6620 |
6654 void Proxy::Revoke() { | 6621 void Proxy::Revoke() { |
6655 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); | 6622 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); |
6656 i::JSProxy::Revoke(self); | 6623 i::JSProxy::Revoke(self); |
6657 } | 6624 } |
6658 | 6625 |
6659 | 6626 |
6660 MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target, | 6627 MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target, |
6661 Local<Object> local_handler) { | 6628 Local<Object> local_handler) { |
6662 PREPARE_FOR_EXECUTION(context, "Proxy::New", Proxy); | 6629 PREPARE_FOR_EXECUTION(context, Proxy, New, Proxy); |
6663 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); | 6630 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); |
6664 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); | 6631 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); |
6665 Local<Proxy> result; | 6632 Local<Proxy> result; |
6666 has_pending_exception = | 6633 has_pending_exception = |
6667 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); | 6634 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); |
6668 RETURN_ON_FAILED_EXECUTION(Proxy); | 6635 RETURN_ON_FAILED_EXECUTION(Proxy); |
6669 RETURN_ESCAPED(result); | 6636 RETURN_ESCAPED(result); |
6670 } | 6637 } |
6671 | 6638 |
6672 bool v8::ArrayBuffer::IsExternal() const { | 6639 bool v8::ArrayBuffer::IsExternal() const { |
6673 return Utils::OpenHandle(this)->is_external(); | 6640 return Utils::OpenHandle(this)->is_external(); |
6674 } | 6641 } |
6675 | 6642 |
6676 | 6643 |
6677 bool v8::ArrayBuffer::IsNeuterable() const { | 6644 bool v8::ArrayBuffer::IsNeuterable() const { |
6678 return Utils::OpenHandle(this)->is_neuterable(); | 6645 return Utils::OpenHandle(this)->is_neuterable(); |
6679 } | 6646 } |
6680 | 6647 |
6681 | 6648 |
6682 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6649 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
6683 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6650 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6684 i::Isolate* isolate = self->GetIsolate(); | 6651 i::Isolate* isolate = self->GetIsolate(); |
6685 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", | 6652 Utils::ApiCheck(!self->is_external(), "v8_ArrayBuffer_Externalize", |
6686 "ArrayBuffer already externalized"); | 6653 "ArrayBuffer already externalized"); |
6687 self->set_is_external(true); | 6654 self->set_is_external(true); |
6688 isolate->heap()->UnregisterArrayBuffer(*self); | 6655 isolate->heap()->UnregisterArrayBuffer(*self); |
6689 | 6656 |
6690 return GetContents(); | 6657 return GetContents(); |
6691 } | 6658 } |
6692 | 6659 |
6693 | 6660 |
6694 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { | 6661 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { |
6695 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6662 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6696 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6663 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
6697 Contents contents; | 6664 Contents contents; |
6698 contents.data_ = self->backing_store(); | 6665 contents.data_ = self->backing_store(); |
6699 contents.byte_length_ = byte_length; | 6666 contents.byte_length_ = byte_length; |
6700 return contents; | 6667 return contents; |
6701 } | 6668 } |
6702 | 6669 |
6703 | 6670 |
6704 void v8::ArrayBuffer::Neuter() { | 6671 void v8::ArrayBuffer::Neuter() { |
6705 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6672 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
6706 i::Isolate* isolate = obj->GetIsolate(); | 6673 i::Isolate* isolate = obj->GetIsolate(); |
6707 Utils::ApiCheck(obj->is_external(), | 6674 Utils::ApiCheck(obj->is_external(), |
6708 "v8::ArrayBuffer::Neuter", | 6675 "v8::ArrayBuffer::Neuter", |
6709 "Only externalized ArrayBuffers can be neutered"); | 6676 "Only externalized ArrayBuffers can be neutered"); |
6710 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter", | 6677 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter", |
6711 "Only neuterable ArrayBuffers can be neutered"); | 6678 "Only neuterable ArrayBuffers can be neutered"); |
6712 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); | 6679 LOG_API(obj->GetIsolate(), ArrayBuffer, Neuter); |
6713 ENTER_V8(isolate); | 6680 ENTER_V8(isolate); |
6714 obj->Neuter(); | 6681 obj->Neuter(); |
6715 } | 6682 } |
6716 | 6683 |
6717 | 6684 |
6718 size_t v8::ArrayBuffer::ByteLength() const { | 6685 size_t v8::ArrayBuffer::ByteLength() const { |
6719 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6686 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
6720 return static_cast<size_t>(obj->byte_length()->Number()); | 6687 return static_cast<size_t>(obj->byte_length()->Number()); |
6721 } | 6688 } |
6722 | 6689 |
6723 | 6690 |
6724 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { | 6691 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
6725 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6692 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6726 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 6693 LOG_API(i_isolate, ArrayBuffer, New); |
6727 ENTER_V8(i_isolate); | 6694 ENTER_V8(i_isolate); |
6728 i::Handle<i::JSArrayBuffer> obj = | 6695 i::Handle<i::JSArrayBuffer> obj = |
6729 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6696 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6730 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); | 6697 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); |
6731 return Utils::ToLocal(obj); | 6698 return Utils::ToLocal(obj); |
6732 } | 6699 } |
6733 | 6700 |
6734 | 6701 |
6735 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 6702 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
6736 size_t byte_length, | 6703 size_t byte_length, |
6737 ArrayBufferCreationMode mode) { | 6704 ArrayBufferCreationMode mode) { |
6738 // Embedders must guarantee that the external backing store is valid. | 6705 // Embedders must guarantee that the external backing store is valid. |
6739 CHECK(byte_length == 0 || data != NULL); | 6706 CHECK(byte_length == 0 || data != NULL); |
6740 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6707 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6741 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6708 LOG_API(i_isolate, ArrayBuffer, New); |
6742 ENTER_V8(i_isolate); | 6709 ENTER_V8(i_isolate); |
6743 i::Handle<i::JSArrayBuffer> obj = | 6710 i::Handle<i::JSArrayBuffer> obj = |
6744 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6711 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
6745 i::JSArrayBuffer::Setup(obj, i_isolate, | 6712 i::JSArrayBuffer::Setup(obj, i_isolate, |
6746 mode == ArrayBufferCreationMode::kExternalized, data, | 6713 mode == ArrayBufferCreationMode::kExternalized, data, |
6747 byte_length); | 6714 byte_length); |
6748 return Utils::ToLocal(obj); | 6715 return Utils::ToLocal(obj); |
6749 } | 6716 } |
6750 | 6717 |
6751 | 6718 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6804 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6771 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6805 return static_cast<size_t>(obj->byte_length()->Number()); | 6772 return static_cast<size_t>(obj->byte_length()->Number()); |
6806 } | 6773 } |
6807 | 6774 |
6808 | 6775 |
6809 size_t v8::TypedArray::Length() { | 6776 size_t v8::TypedArray::Length() { |
6810 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); | 6777 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); |
6811 return static_cast<size_t>(obj->length_value()); | 6778 return static_cast<size_t>(obj->length_value()); |
6812 } | 6779 } |
6813 | 6780 |
6814 | 6781 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ |
6815 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ | 6782 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ |
6816 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ | 6783 size_t byte_offset, size_t length) { \ |
6817 size_t byte_offset, size_t length) { \ | 6784 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ |
6818 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ | 6785 LOG_API(isolate, Type##Array, New); \ |
6819 LOG_API(isolate, \ | 6786 ENTER_V8(isolate); \ |
6820 "v8::" #Type "Array::New(Local<ArrayBuffer>, size_t, size_t)"); \ | 6787 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
6821 ENTER_V8(isolate); \ | 6788 "v8::" #Type \ |
6822 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6789 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ |
6823 "v8::" #Type \ | 6790 "length exceeds max allowed value")) { \ |
6824 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ | 6791 return Local<Type##Array>(); \ |
6825 "length exceeds max allowed value")) { \ | 6792 } \ |
6826 return Local<Type##Array>(); \ | 6793 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ |
6827 } \ | 6794 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
6828 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ | 6795 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
6829 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | 6796 return Utils::ToLocal##Type##Array(obj); \ |
6830 i::kExternal##Type##Array, buffer, byte_offset, length); \ | 6797 } \ |
6831 return Utils::ToLocal##Type##Array(obj); \ | 6798 Local<Type##Array> Type##Array::New( \ |
6832 } \ | 6799 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ |
6833 Local<Type##Array> Type##Array::New( \ | 6800 size_t length) { \ |
6834 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ | 6801 CHECK(i::FLAG_harmony_sharedarraybuffer); \ |
6835 size_t length) { \ | 6802 i::Isolate* isolate = \ |
6836 CHECK(i::FLAG_harmony_sharedarraybuffer); \ | 6803 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ |
6837 i::Isolate* isolate = \ | 6804 LOG_API(isolate, Type##Array, New); \ |
6838 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ | 6805 ENTER_V8(isolate); \ |
6839 LOG_API(isolate, "v8::" #Type \ | 6806 if (!Utils::ApiCheck( \ |
6840 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)"); \ | 6807 length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
6841 ENTER_V8(isolate); \ | 6808 "v8::" #Type \ |
6842 if (!Utils::ApiCheck( \ | 6809 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ |
6843 length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6810 "length exceeds max allowed value")) { \ |
6844 "v8::" #Type \ | 6811 return Local<Type##Array>(); \ |
6845 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ | 6812 } \ |
6846 "length exceeds max allowed value")) { \ | 6813 i::Handle<i::JSArrayBuffer> buffer = \ |
6847 return Local<Type##Array>(); \ | 6814 Utils::OpenHandle(*shared_array_buffer); \ |
6848 } \ | 6815 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
6849 i::Handle<i::JSArrayBuffer> buffer = \ | 6816 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
6850 Utils::OpenHandle(*shared_array_buffer); \ | 6817 return Utils::ToLocal##Type##Array(obj); \ |
6851 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | |
6852 i::kExternal##Type##Array, buffer, byte_offset, length); \ | |
6853 return Utils::ToLocal##Type##Array(obj); \ | |
6854 } | 6818 } |
6855 | 6819 |
6856 | |
6857 TYPED_ARRAYS(TYPED_ARRAY_NEW) | 6820 TYPED_ARRAYS(TYPED_ARRAY_NEW) |
6858 #undef TYPED_ARRAY_NEW | 6821 #undef TYPED_ARRAY_NEW |
6859 | 6822 |
6860 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, | 6823 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, |
6861 size_t byte_offset, size_t byte_length) { | 6824 size_t byte_offset, size_t byte_length) { |
6862 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); | 6825 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); |
6863 i::Isolate* isolate = buffer->GetIsolate(); | 6826 i::Isolate* isolate = buffer->GetIsolate(); |
6864 LOG_API(isolate, "v8::DataView::New(Local<ArrayBuffer>, size_t, size_t)"); | 6827 LOG_API(isolate, DataView, New); |
6865 ENTER_V8(isolate); | 6828 ENTER_V8(isolate); |
6866 i::Handle<i::JSDataView> obj = | 6829 i::Handle<i::JSDataView> obj = |
6867 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6830 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
6868 return Utils::ToLocal(obj); | 6831 return Utils::ToLocal(obj); |
6869 } | 6832 } |
6870 | 6833 |
6871 | 6834 |
6872 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, | 6835 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, |
6873 size_t byte_offset, size_t byte_length) { | 6836 size_t byte_offset, size_t byte_length) { |
6874 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6837 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6875 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); | 6838 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); |
6876 i::Isolate* isolate = buffer->GetIsolate(); | 6839 i::Isolate* isolate = buffer->GetIsolate(); |
6877 LOG_API(isolate, | 6840 LOG_API(isolate, DataView, New); |
6878 "v8::DataView::New(Local<SharedArrayBuffer>, size_t, size_t)"); | |
6879 ENTER_V8(isolate); | 6841 ENTER_V8(isolate); |
6880 i::Handle<i::JSDataView> obj = | 6842 i::Handle<i::JSDataView> obj = |
6881 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6843 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
6882 return Utils::ToLocal(obj); | 6844 return Utils::ToLocal(obj); |
6883 } | 6845 } |
6884 | 6846 |
6885 | 6847 |
6886 bool v8::SharedArrayBuffer::IsExternal() const { | 6848 bool v8::SharedArrayBuffer::IsExternal() const { |
6887 return Utils::OpenHandle(this)->is_external(); | 6849 return Utils::OpenHandle(this)->is_external(); |
6888 } | 6850 } |
6889 | 6851 |
6890 | 6852 |
6891 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { | 6853 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { |
6892 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6854 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6893 i::Isolate* isolate = self->GetIsolate(); | 6855 i::Isolate* isolate = self->GetIsolate(); |
6894 Utils::ApiCheck(!self->is_external(), "v8::SharedArrayBuffer::Externalize", | 6856 Utils::ApiCheck(!self->is_external(), "v8_SharedArrayBuffer_Externalize", |
6895 "SharedArrayBuffer already externalized"); | 6857 "SharedArrayBuffer already externalized"); |
6896 self->set_is_external(true); | 6858 self->set_is_external(true); |
6897 isolate->heap()->UnregisterArrayBuffer(*self); | 6859 isolate->heap()->UnregisterArrayBuffer(*self); |
6898 return GetContents(); | 6860 return GetContents(); |
6899 } | 6861 } |
6900 | 6862 |
6901 | 6863 |
6902 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { | 6864 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { |
6903 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6865 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
6904 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6866 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
6905 Contents contents; | 6867 Contents contents; |
6906 contents.data_ = self->backing_store(); | 6868 contents.data_ = self->backing_store(); |
6907 contents.byte_length_ = byte_length; | 6869 contents.byte_length_ = byte_length; |
6908 return contents; | 6870 return contents; |
6909 } | 6871 } |
6910 | 6872 |
6911 | 6873 |
6912 size_t v8::SharedArrayBuffer::ByteLength() const { | 6874 size_t v8::SharedArrayBuffer::ByteLength() const { |
6913 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6875 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
6914 return static_cast<size_t>(obj->byte_length()->Number()); | 6876 return static_cast<size_t>(obj->byte_length()->Number()); |
6915 } | 6877 } |
6916 | 6878 |
6917 | 6879 |
6918 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, | 6880 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, |
6919 size_t byte_length) { | 6881 size_t byte_length) { |
6920 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6882 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6921 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6883 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6922 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(size_t)"); | 6884 LOG_API(i_isolate, SharedArrayBuffer, New); |
6923 ENTER_V8(i_isolate); | 6885 ENTER_V8(i_isolate); |
6924 i::Handle<i::JSArrayBuffer> obj = | 6886 i::Handle<i::JSArrayBuffer> obj = |
6925 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6887 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
6926 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, | 6888 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, |
6927 i::SharedFlag::kShared); | 6889 i::SharedFlag::kShared); |
6928 return Utils::ToLocalShared(obj); | 6890 return Utils::ToLocalShared(obj); |
6929 } | 6891 } |
6930 | 6892 |
6931 | 6893 |
6932 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 6894 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
6933 Isolate* isolate, void* data, size_t byte_length, | 6895 Isolate* isolate, void* data, size_t byte_length, |
6934 ArrayBufferCreationMode mode) { | 6896 ArrayBufferCreationMode mode) { |
6935 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6897 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6936 // Embedders must guarantee that the external backing store is valid. | 6898 // Embedders must guarantee that the external backing store is valid. |
6937 CHECK(byte_length == 0 || data != NULL); | 6899 CHECK(byte_length == 0 || data != NULL); |
6938 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6900 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6939 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); | 6901 LOG_API(i_isolate, SharedArrayBuffer, New); |
6940 ENTER_V8(i_isolate); | 6902 ENTER_V8(i_isolate); |
6941 i::Handle<i::JSArrayBuffer> obj = | 6903 i::Handle<i::JSArrayBuffer> obj = |
6942 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6904 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
6943 i::JSArrayBuffer::Setup(obj, i_isolate, | 6905 i::JSArrayBuffer::Setup(obj, i_isolate, |
6944 mode == ArrayBufferCreationMode::kExternalized, data, | 6906 mode == ArrayBufferCreationMode::kExternalized, data, |
6945 byte_length, i::SharedFlag::kShared); | 6907 byte_length, i::SharedFlag::kShared); |
6946 return Utils::ToLocalShared(obj); | 6908 return Utils::ToLocalShared(obj); |
6947 } | 6909 } |
6948 | 6910 |
6949 | 6911 |
6950 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { | 6912 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { |
6951 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6913 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6952 LOG_API(i_isolate, "Symbol::New()"); | 6914 LOG_API(i_isolate, Symbol, New); |
6953 ENTER_V8(i_isolate); | 6915 ENTER_V8(i_isolate); |
6954 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6916 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
6955 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); | 6917 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); |
6956 return Utils::ToLocal(result); | 6918 return Utils::ToLocal(result); |
6957 } | 6919 } |
6958 | 6920 |
6959 | 6921 |
6960 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, | 6922 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, |
6961 i::Handle<i::String> name, | 6923 i::Handle<i::String> name, |
6962 i::Handle<i::String> part, | 6924 i::Handle<i::String> part, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7015 | 6977 |
7016 | 6978 |
7017 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { | 6979 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { |
7018 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6980 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7019 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); | 6981 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); |
7020 } | 6982 } |
7021 | 6983 |
7022 | 6984 |
7023 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 6985 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
7024 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6986 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7025 LOG_API(i_isolate, "Private::New()"); | 6987 LOG_API(i_isolate, Private, New); |
7026 ENTER_V8(i_isolate); | 6988 ENTER_V8(i_isolate); |
7027 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6989 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
7028 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6990 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
7029 Local<Symbol> result = Utils::ToLocal(symbol); | 6991 Local<Symbol> result = Utils::ToLocal(symbol); |
7030 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); | 6992 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); |
7031 } | 6993 } |
7032 | 6994 |
7033 | 6995 |
7034 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { | 6996 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { |
7035 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6997 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7947 length_ = str->Length(); | 7909 length_ = str->Length(); |
7948 str_ = i::NewArray<uint16_t>(length_ + 1); | 7910 str_ = i::NewArray<uint16_t>(length_ + 1); |
7949 str->Write(str_); | 7911 str->Write(str_); |
7950 } | 7912 } |
7951 | 7913 |
7952 | 7914 |
7953 String::Value::~Value() { | 7915 String::Value::~Value() { |
7954 i::DeleteArray(str_); | 7916 i::DeleteArray(str_); |
7955 } | 7917 } |
7956 | 7918 |
7957 | |
7958 #define DEFINE_ERROR(NAME, name) \ | 7919 #define DEFINE_ERROR(NAME, name) \ |
7959 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ | 7920 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ |
7960 i::Isolate* isolate = i::Isolate::Current(); \ | 7921 i::Isolate* isolate = i::Isolate::Current(); \ |
7961 LOG_API(isolate, #NAME); \ | 7922 LOG_API(isolate, NAME, New); \ |
7962 ENTER_V8(isolate); \ | 7923 ENTER_V8(isolate); \ |
7963 i::Object* error; \ | 7924 i::Object* error; \ |
7964 { \ | 7925 { \ |
7965 i::HandleScope scope(isolate); \ | 7926 i::HandleScope scope(isolate); \ |
7966 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ | 7927 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ |
7967 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \ | 7928 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \ |
7968 error = *isolate->factory()->NewError(constructor, message); \ | 7929 error = *isolate->factory()->NewError(constructor, message); \ |
7969 } \ | 7930 } \ |
7970 i::Handle<i::Object> result(error, isolate); \ | 7931 i::Handle<i::Object> result(error, isolate); \ |
7971 return Utils::ToLocal(result); \ | 7932 return Utils::ToLocal(result); \ |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8067 ClientData* client_data) { | 8028 ClientData* client_data) { |
8068 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8029 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
8069 internal_isolate->debug()->EnqueueCommandMessage( | 8030 internal_isolate->debug()->EnqueueCommandMessage( |
8070 i::Vector<const uint16_t>(command, length), client_data); | 8031 i::Vector<const uint16_t>(command, length), client_data); |
8071 } | 8032 } |
8072 | 8033 |
8073 | 8034 |
8074 MaybeLocal<Value> Debug::Call(Local<Context> context, | 8035 MaybeLocal<Value> Debug::Call(Local<Context> context, |
8075 v8::Local<v8::Function> fun, | 8036 v8::Local<v8::Function> fun, |
8076 v8::Local<v8::Value> data) { | 8037 v8::Local<v8::Value> data) { |
8077 PREPARE_FOR_EXECUTION(context, "v8::Debug::Call()", Value); | 8038 PREPARE_FOR_EXECUTION(context, Debug, Call, Value); |
8078 i::Handle<i::Object> data_obj; | 8039 i::Handle<i::Object> data_obj; |
8079 if (data.IsEmpty()) { | 8040 if (data.IsEmpty()) { |
8080 data_obj = isolate->factory()->undefined_value(); | 8041 data_obj = isolate->factory()->undefined_value(); |
8081 } else { | 8042 } else { |
8082 data_obj = Utils::OpenHandle(*data); | 8043 data_obj = Utils::OpenHandle(*data); |
8083 } | 8044 } |
8084 Local<Value> result; | 8045 Local<Value> result; |
8085 has_pending_exception = | 8046 has_pending_exception = |
8086 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), | 8047 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), |
8087 &result); | 8048 &result); |
8088 RETURN_ON_FAILED_EXECUTION(Value); | 8049 RETURN_ON_FAILED_EXECUTION(Value); |
8089 RETURN_ESCAPED(result); | 8050 RETURN_ESCAPED(result); |
8090 } | 8051 } |
8091 | 8052 |
8092 | 8053 |
8093 Local<Value> Debug::Call(v8::Local<v8::Function> fun, | 8054 Local<Value> Debug::Call(v8::Local<v8::Function> fun, |
8094 v8::Local<v8::Value> data) { | 8055 v8::Local<v8::Value> data) { |
8095 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); | 8056 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); |
8096 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); | 8057 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); |
8097 } | 8058 } |
8098 | 8059 |
8099 | 8060 |
8100 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, | 8061 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, |
8101 v8::Local<v8::Value> obj) { | 8062 v8::Local<v8::Value> obj) { |
8102 PREPARE_FOR_EXECUTION(context, "v8::Debug::GetMirror()", Value); | 8063 PREPARE_FOR_EXECUTION(context, Debug, GetMirror, Value); |
8103 i::Debug* isolate_debug = isolate->debug(); | 8064 i::Debug* isolate_debug = isolate->debug(); |
8104 has_pending_exception = !isolate_debug->Load(); | 8065 has_pending_exception = !isolate_debug->Load(); |
8105 RETURN_ON_FAILED_EXECUTION(Value); | 8066 RETURN_ON_FAILED_EXECUTION(Value); |
8106 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 8067 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
8107 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); | 8068 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); |
8108 auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked(); | 8069 auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked(); |
8109 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); | 8070 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); |
8110 const int kArgc = 1; | 8071 const int kArgc = 1; |
8111 v8::Local<v8::Value> argv[kArgc] = {obj}; | 8072 v8::Local<v8::Value> argv[kArgc] = {obj}; |
8112 Local<Value> result; | 8073 Local<Value> result; |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8812 } | 8773 } |
8813 } | 8774 } |
8814 | 8775 |
8815 | 8776 |
8816 void InvokeAccessorGetterCallback( | 8777 void InvokeAccessorGetterCallback( |
8817 v8::Local<v8::Name> property, | 8778 v8::Local<v8::Name> property, |
8818 const v8::PropertyCallbackInfo<v8::Value>& info, | 8779 const v8::PropertyCallbackInfo<v8::Value>& info, |
8819 v8::AccessorNameGetterCallback getter) { | 8780 v8::AccessorNameGetterCallback getter) { |
8820 // Leaving JavaScript. | 8781 // Leaving JavaScript. |
8821 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8782 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8783 RuntimeCallTimerScope timer(isolate, |
| 8784 &RuntimeCallStats::AccessorGetterCallback); |
8822 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( | 8785 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( |
8823 getter)); | 8786 getter)); |
8824 VMState<EXTERNAL> state(isolate); | 8787 VMState<EXTERNAL> state(isolate); |
8825 ExternalCallbackScope call_scope(isolate, getter_address); | 8788 ExternalCallbackScope call_scope(isolate, getter_address); |
8826 getter(property, info); | 8789 getter(property, info); |
8827 } | 8790 } |
8828 | 8791 |
8829 | 8792 |
8830 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, | 8793 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, |
8831 v8::FunctionCallback callback) { | 8794 v8::FunctionCallback callback) { |
8832 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8795 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8796 RuntimeCallTimerScope timer(isolate, |
| 8797 &RuntimeCallStats::InvokeFunctionCallback); |
8833 Address callback_address = | 8798 Address callback_address = |
8834 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8799 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8835 VMState<EXTERNAL> state(isolate); | 8800 VMState<EXTERNAL> state(isolate); |
8836 ExternalCallbackScope call_scope(isolate, callback_address); | 8801 ExternalCallbackScope call_scope(isolate, callback_address); |
8837 callback(info); | 8802 callback(info); |
8838 } | 8803 } |
8839 | 8804 |
8840 | 8805 |
8841 } // namespace internal | 8806 } // namespace internal |
8842 } // namespace v8 | 8807 } // namespace v8 |
OLD | NEW |