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