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