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 i::Isolate* _log_isolate = isolate; \ |
|
jochen (gone - plz use gerrit)
2016/05/06 09:39:54
why's that required?
| |
| 73 RUNTIME_COUNTER(_log_isolate, counter); \ | |
| 74 LOG(_log_isolate, ApiEntryCall(#message)) | |
| 73 | 75 |
| 74 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) | 76 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) |
| 75 | 77 |
| 78 #define COMPILE_MESSAGE(x) _Pragma(#x) | |
| 79 #define PRAGMA_MESSAGE(x) COMPILE_MESSAGE(message(" " #x)) | |
| 76 | 80 |
| 77 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 81 #define RUNTIME_COUNTER(isolate, name) \ |
| 78 bailout_value, HandleScopeClass, \ | 82 i::RuntimeCallStats* _runtime_stats = \ |
| 79 do_callback) \ | 83 isolate->counters()->runtime_call_stats(); \ |
| 80 if (IsExecutionTerminatingCheck(isolate)) { \ | 84 i::RuntimeCallTimerScope _runtime_timer(isolate, &_runtime_stats->API_##name); |
| 81 return bailout_value; \ | 85 |
| 82 } \ | 86 #define PREPARE_FOR_EXECUTION_GENERIC(isolate, context, counter_name, \ |
| 83 HandleScopeClass handle_scope(isolate); \ | 87 function_name, bailout_value, \ |
| 84 CallDepthScope call_depth_scope(isolate, context, do_callback); \ | 88 HandleScopeClass, do_callback) \ |
| 85 LOG_API(isolate, function_name); \ | 89 if (IsExecutionTerminatingCheck(isolate)) { \ |
| 86 ENTER_V8(isolate); \ | 90 return bailout_value; \ |
| 91 } \ | |
| 92 HandleScopeClass handle_scope(isolate); \ | |
| 93 CallDepthScope call_depth_scope(isolate, context, do_callback); \ | |
| 94 LOG_API(isolate, counter_name, function_name); \ | |
| 95 ENTER_V8(isolate); \ | |
| 87 bool has_pending_exception = false | 96 bool has_pending_exception = false |
| 88 | 97 |
| 89 | 98 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, counter_name, \ |
| 90 #define PREPARE_FOR_EXECUTION_WITH_CONTEXT( \ | 99 function_name, bailout_value, \ |
| 91 context, function_name, bailout_value, HandleScopeClass, do_callback) \ | 100 HandleScopeClass, do_callback) \ |
| 92 auto isolate = context.IsEmpty() \ | 101 auto isolate = context.IsEmpty() \ |
| 93 ? i::Isolate::Current() \ | 102 ? i::Isolate::Current() \ |
| 94 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ | 103 : reinterpret_cast<i::Isolate*>(context->GetIsolate()); \ |
| 95 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, function_name, \ | 104 PREPARE_FOR_EXECUTION_GENERIC(isolate, context, counter_name, function_name, \ |
| 96 bailout_value, HandleScopeClass, do_callback); | 105 bailout_value, HandleScopeClass, do_callback); |
| 97 | 106 |
| 107 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, counter_name, \ | |
| 108 function_name, T) \ | |
| 109 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), counter_name, \ | |
| 110 function_name, MaybeLocal<T>(), \ | |
| 111 InternalEscapableScope, false); | |
| 98 | 112 |
| 99 #define PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, function_name, T) \ | 113 #define PREPARE_FOR_EXECUTION(context, counter_name, function_name, T) \ |
| 100 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), function_name, \ | 114 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, counter_name, function_name, \ |
| 101 MaybeLocal<T>(), InternalEscapableScope, \ | 115 MaybeLocal<T>(), InternalEscapableScope, \ |
| 102 false); | 116 false) |
| 103 | 117 |
| 118 #define PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, counter_name, \ | |
| 119 function_name, T) \ | |
| 120 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, counter_name, function_name, \ | |
| 121 MaybeLocal<T>(), InternalEscapableScope, \ | |
| 122 true) | |
| 104 | 123 |
| 105 #define PREPARE_FOR_EXECUTION(context, function_name, T) \ | 124 #define PREPARE_FOR_EXECUTION_PRIMITIVE(context, counter_name, function_name, \ |
| 106 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, function_name, MaybeLocal<T>(), \ | 125 T) \ |
| 107 InternalEscapableScope, false) | 126 PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, counter_name, function_name, \ |
| 108 | 127 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 | 128 |
| 120 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ | 129 #define EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, value) \ |
| 121 do { \ | 130 do { \ |
| 122 if (has_pending_exception) { \ | 131 if (has_pending_exception) { \ |
| 123 call_depth_scope.Escape(); \ | 132 call_depth_scope.Escape(); \ |
| 124 return value; \ | 133 return value; \ |
| 125 } \ | 134 } \ |
| 126 } while (false) | 135 } while (false) |
| 127 | 136 |
| 128 | 137 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 max_executable_size, code_range_size); | 659 max_executable_size, code_range_size); |
| 651 } | 660 } |
| 652 if (constraints.stack_limit() != NULL) { | 661 if (constraints.stack_limit() != NULL) { |
| 653 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); | 662 uintptr_t limit = reinterpret_cast<uintptr_t>(constraints.stack_limit()); |
| 654 isolate->stack_guard()->SetStackLimit(limit); | 663 isolate->stack_guard()->SetStackLimit(limit); |
| 655 } | 664 } |
| 656 } | 665 } |
| 657 | 666 |
| 658 | 667 |
| 659 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { | 668 i::Object** V8::GlobalizeReference(i::Isolate* isolate, i::Object** obj) { |
| 660 LOG_API(isolate, "Persistent::New"); | 669 LOG_API(isolate, Persistent_New, "Persistent::New"); |
| 661 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); | 670 i::Handle<i::Object> result = isolate->global_handles()->Create(*obj); |
| 662 #ifdef VERIFY_HEAP | 671 #ifdef VERIFY_HEAP |
| 663 if (i::FLAG_verify_heap) { | 672 if (i::FLAG_verify_heap) { |
| 664 (*obj)->ObjectVerify(); | 673 (*obj)->ObjectVerify(); |
| 665 } | 674 } |
| 666 #endif // VERIFY_HEAP | 675 #endif // VERIFY_HEAP |
| 667 return result.location(); | 676 return result.location(); |
| 668 } | 677 } |
| 669 | 678 |
| 670 | 679 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 | 1148 |
| 1140 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, | 1149 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, |
| 1141 FunctionCallback callback, | 1150 FunctionCallback callback, |
| 1142 v8::Local<Value> data, | 1151 v8::Local<Value> data, |
| 1143 v8::Local<Signature> signature, | 1152 v8::Local<Signature> signature, |
| 1144 int length) { | 1153 int length) { |
| 1145 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1154 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1146 // Changes to the environment cannot be captured in the snapshot. Expect no | 1155 // Changes to the environment cannot be captured in the snapshot. Expect no |
| 1147 // function templates when the isolate is created for serialization. | 1156 // function templates when the isolate is created for serialization. |
| 1148 DCHECK(!i_isolate->serializer_enabled()); | 1157 DCHECK(!i_isolate->serializer_enabled()); |
| 1149 LOG_API(i_isolate, "FunctionTemplate::New"); | 1158 LOG_API(i_isolate, FunctionTemplate_New, "FunctionTemplate::New"); |
| 1150 ENTER_V8(i_isolate); | 1159 ENTER_V8(i_isolate); |
| 1151 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, | 1160 return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, |
| 1152 length, false); | 1161 length, false); |
| 1153 } | 1162 } |
| 1154 | 1163 |
| 1155 | 1164 |
| 1156 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( | 1165 Local<FunctionTemplate> FunctionTemplate::NewWithFastHandler( |
| 1157 Isolate* isolate, FunctionCallback callback, | 1166 Isolate* isolate, FunctionCallback callback, |
| 1158 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, | 1167 experimental::FastAccessorBuilder* fast_handler, v8::Local<Value> data, |
| 1159 v8::Local<Signature> signature, int length) { | 1168 v8::Local<Signature> signature, int length) { |
| 1160 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1169 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1161 DCHECK(!i_isolate->serializer_enabled()); | 1170 DCHECK(!i_isolate->serializer_enabled()); |
| 1162 LOG_API(i_isolate, "FunctionTemplate::NewWithFastHandler"); | 1171 LOG_API(i_isolate, FunctionTemplate_NewWithFastHandler, |
| 1172 "FunctionTemplate::NewWithFastHandler"); | |
| 1163 ENTER_V8(i_isolate); | 1173 ENTER_V8(i_isolate); |
| 1164 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, | 1174 return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, |
| 1165 length, false); | 1175 length, false); |
| 1166 } | 1176 } |
| 1167 | 1177 |
| 1168 | 1178 |
| 1169 Local<Signature> Signature::New(Isolate* isolate, | 1179 Local<Signature> Signature::New(Isolate* isolate, |
| 1170 Local<FunctionTemplate> receiver) { | 1180 Local<FunctionTemplate> receiver) { |
| 1171 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); | 1181 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); |
| 1172 } | 1182 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1336 Local<ObjectTemplate> ObjectTemplate::New() { | 1346 Local<ObjectTemplate> ObjectTemplate::New() { |
| 1337 return New(i::Isolate::Current(), Local<FunctionTemplate>()); | 1347 return New(i::Isolate::Current(), Local<FunctionTemplate>()); |
| 1338 } | 1348 } |
| 1339 | 1349 |
| 1340 static Local<ObjectTemplate> ObjectTemplateNew( | 1350 static Local<ObjectTemplate> ObjectTemplateNew( |
| 1341 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, | 1351 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor, |
| 1342 bool do_not_cache) { | 1352 bool do_not_cache) { |
| 1343 // Changes to the environment cannot be captured in the snapshot. Expect no | 1353 // Changes to the environment cannot be captured in the snapshot. Expect no |
| 1344 // object templates when the isolate is created for serialization. | 1354 // object templates when the isolate is created for serialization. |
| 1345 DCHECK(!isolate->serializer_enabled()); | 1355 DCHECK(!isolate->serializer_enabled()); |
| 1346 LOG_API(isolate, "ObjectTemplate::New"); | 1356 LOG_API(isolate, ObjectTemplate_New, "ObjectTemplate::New"); |
| 1347 ENTER_V8(isolate); | 1357 ENTER_V8(isolate); |
| 1348 i::Handle<i::Struct> struct_obj = | 1358 i::Handle<i::Struct> struct_obj = |
| 1349 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1359 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
| 1350 i::Handle<i::ObjectTemplateInfo> obj = | 1360 i::Handle<i::ObjectTemplateInfo> obj = |
| 1351 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1361 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
| 1352 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1362 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
| 1353 int next_serial_number = 0; | 1363 int next_serial_number = 0; |
| 1354 if (!do_not_cache) { | 1364 if (!do_not_cache) { |
| 1355 next_serial_number = isolate->next_serial_number() + 1; | 1365 next_serial_number = isolate->next_serial_number() + 1; |
| 1356 isolate->set_next_serial_number(next_serial_number); | 1366 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( | 1724 obj->GetIsolate()->factory()->NewFunctionFromSharedFunctionInfo( |
| 1715 function_info, isolate->native_context()); | 1725 function_info, isolate->native_context()); |
| 1716 return ToApiHandle<Script>(function); | 1726 return ToApiHandle<Script>(function); |
| 1717 } | 1727 } |
| 1718 | 1728 |
| 1719 | 1729 |
| 1720 int UnboundScript::GetId() { | 1730 int UnboundScript::GetId() { |
| 1721 i::Handle<i::HeapObject> obj = | 1731 i::Handle<i::HeapObject> obj = |
| 1722 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); | 1732 i::Handle<i::HeapObject>::cast(Utils::OpenHandle(this)); |
| 1723 i::Isolate* isolate = obj->GetIsolate(); | 1733 i::Isolate* isolate = obj->GetIsolate(); |
| 1724 LOG_API(isolate, "v8::UnboundScript::GetId"); | 1734 LOG_API(isolate, v8_UnboundScript_GetId, "v8::UnboundScript::GetId"); |
| 1725 i::HandleScope scope(isolate); | 1735 i::HandleScope scope(isolate); |
| 1726 i::Handle<i::SharedFunctionInfo> function_info( | 1736 i::Handle<i::SharedFunctionInfo> function_info( |
| 1727 i::SharedFunctionInfo::cast(*obj)); | 1737 i::SharedFunctionInfo::cast(*obj)); |
| 1728 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1738 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
| 1729 return script->id(); | 1739 return script->id(); |
| 1730 } | 1740 } |
| 1731 | 1741 |
| 1732 | 1742 |
| 1733 int UnboundScript::GetLineNumber(int code_pos) { | 1743 int UnboundScript::GetLineNumber(int code_pos) { |
| 1734 i::Handle<i::SharedFunctionInfo> obj = | 1744 i::Handle<i::SharedFunctionInfo> obj = |
| 1735 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1745 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
| 1736 i::Isolate* isolate = obj->GetIsolate(); | 1746 i::Isolate* isolate = obj->GetIsolate(); |
| 1737 LOG_API(isolate, "UnboundScript::GetLineNumber"); | 1747 LOG_API(isolate, UnboundScript_GetLineNumber, "UnboundScript::GetLineNumber"); |
| 1738 if (obj->script()->IsScript()) { | 1748 if (obj->script()->IsScript()) { |
| 1739 i::Handle<i::Script> script(i::Script::cast(obj->script())); | 1749 i::Handle<i::Script> script(i::Script::cast(obj->script())); |
| 1740 return i::Script::GetLineNumber(script, code_pos); | 1750 return i::Script::GetLineNumber(script, code_pos); |
| 1741 } else { | 1751 } else { |
| 1742 return -1; | 1752 return -1; |
| 1743 } | 1753 } |
| 1744 } | 1754 } |
| 1745 | 1755 |
| 1746 | 1756 |
| 1747 Local<Value> UnboundScript::GetScriptName() { | 1757 Local<Value> UnboundScript::GetScriptName() { |
| 1748 i::Handle<i::SharedFunctionInfo> obj = | 1758 i::Handle<i::SharedFunctionInfo> obj = |
| 1749 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1759 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
| 1750 i::Isolate* isolate = obj->GetIsolate(); | 1760 i::Isolate* isolate = obj->GetIsolate(); |
| 1751 LOG_API(isolate, "UnboundScript::GetName"); | 1761 LOG_API(isolate, UnboundScript_GetName, "UnboundScript::GetName"); |
| 1752 if (obj->script()->IsScript()) { | 1762 if (obj->script()->IsScript()) { |
| 1753 i::Object* name = i::Script::cast(obj->script())->name(); | 1763 i::Object* name = i::Script::cast(obj->script())->name(); |
| 1754 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); | 1764 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); |
| 1755 } else { | 1765 } else { |
| 1756 return Local<String>(); | 1766 return Local<String>(); |
| 1757 } | 1767 } |
| 1758 } | 1768 } |
| 1759 | 1769 |
| 1760 | 1770 |
| 1761 Local<Value> UnboundScript::GetSourceURL() { | 1771 Local<Value> UnboundScript::GetSourceURL() { |
| 1762 i::Handle<i::SharedFunctionInfo> obj = | 1772 i::Handle<i::SharedFunctionInfo> obj = |
| 1763 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1773 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
| 1764 i::Isolate* isolate = obj->GetIsolate(); | 1774 i::Isolate* isolate = obj->GetIsolate(); |
| 1765 LOG_API(isolate, "UnboundScript::GetSourceURL"); | 1775 LOG_API(isolate, UnboundScript_GetSourceURL, "UnboundScript::GetSourceURL"); |
| 1766 if (obj->script()->IsScript()) { | 1776 if (obj->script()->IsScript()) { |
| 1767 i::Object* url = i::Script::cast(obj->script())->source_url(); | 1777 i::Object* url = i::Script::cast(obj->script())->source_url(); |
| 1768 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1778 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
| 1769 } else { | 1779 } else { |
| 1770 return Local<String>(); | 1780 return Local<String>(); |
| 1771 } | 1781 } |
| 1772 } | 1782 } |
| 1773 | 1783 |
| 1774 | 1784 |
| 1775 Local<Value> UnboundScript::GetSourceMappingURL() { | 1785 Local<Value> UnboundScript::GetSourceMappingURL() { |
| 1776 i::Handle<i::SharedFunctionInfo> obj = | 1786 i::Handle<i::SharedFunctionInfo> obj = |
| 1777 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1787 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
| 1778 i::Isolate* isolate = obj->GetIsolate(); | 1788 i::Isolate* isolate = obj->GetIsolate(); |
| 1779 LOG_API(isolate, "UnboundScript::GetSourceMappingURL"); | 1789 LOG_API(isolate, UnboundScript_GetSourceMappingURL, |
| 1790 "UnboundScript::GetSourceMappingURL"); | |
| 1780 if (obj->script()->IsScript()) { | 1791 if (obj->script()->IsScript()) { |
| 1781 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); | 1792 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); |
| 1782 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1793 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
| 1783 } else { | 1794 } else { |
| 1784 return Local<String>(); | 1795 return Local<String>(); |
| 1785 } | 1796 } |
| 1786 } | 1797 } |
| 1787 | 1798 |
| 1788 | 1799 |
| 1789 MaybeLocal<Value> Script::Run(Local<Context> context) { | 1800 MaybeLocal<Value> Script::Run(Local<Context> context) { |
| 1790 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) | 1801 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, v8_Script_Run, "v8::Script::Run", |
| 1802 Value) | |
| 1791 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1803 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 1792 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 1804 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 1793 TRACE_EVENT0("v8", "V8.Execute"); | 1805 TRACE_EVENT0("v8", "V8.Execute"); |
| 1794 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); | 1806 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); |
| 1795 i::Handle<i::Object> receiver = isolate->global_proxy(); | 1807 i::Handle<i::Object> receiver = isolate->global_proxy(); |
| 1796 Local<Value> result; | 1808 Local<Value> result; |
| 1797 has_pending_exception = | 1809 has_pending_exception = |
| 1798 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), | 1810 !ToLocal<Value>(i::Execution::Call(isolate, fun, receiver, 0, NULL), |
| 1799 &result); | 1811 &result); |
| 1800 RETURN_ON_FAILED_EXECUTION(Value); | 1812 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1816 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1828 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 1817 return ToApiHandle<UnboundScript>( | 1829 return ToApiHandle<UnboundScript>( |
| 1818 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); | 1830 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
| 1819 } | 1831 } |
| 1820 | 1832 |
| 1821 | 1833 |
| 1822 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( | 1834 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( |
| 1823 Isolate* v8_isolate, Source* source, CompileOptions options, | 1835 Isolate* v8_isolate, Source* source, CompileOptions options, |
| 1824 bool is_module) { | 1836 bool is_module) { |
| 1825 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1837 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 1826 PREPARE_FOR_EXECUTION_WITH_ISOLATE( | 1838 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, v8_ScriptCompiler_CompileUnbound, |
| 1827 isolate, "v8::ScriptCompiler::CompileUnbound()", UnboundScript); | 1839 "v8::ScriptCompiler::CompileUnbound", |
| 1840 UnboundScript); | |
| 1828 | 1841 |
| 1829 // Don't try to produce any kind of cache when the debugger is loaded. | 1842 // Don't try to produce any kind of cache when the debugger is loaded. |
| 1830 if (isolate->debug()->is_loaded() && | 1843 if (isolate->debug()->is_loaded() && |
| 1831 (options == kProduceParserCache || options == kProduceCodeCache)) { | 1844 (options == kProduceParserCache || options == kProduceCodeCache)) { |
| 1832 options = kNoCompileOptions; | 1845 options = kNoCompileOptions; |
| 1833 } | 1846 } |
| 1834 | 1847 |
| 1835 i::ScriptData* script_data = NULL; | 1848 i::ScriptData* script_data = NULL; |
| 1836 if (options == kConsumeParserCache || options == kConsumeCodeCache) { | 1849 if (options == kConsumeParserCache || options == kConsumeCodeCache) { |
| 1837 DCHECK(source->cached_data); | 1850 DCHECK(source->cached_data); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1976 bool first_char_; | 1989 bool first_char_; |
| 1977 i::UnicodeCache unicode_cache_; | 1990 i::UnicodeCache unicode_cache_; |
| 1978 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); | 1991 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); |
| 1979 }; | 1992 }; |
| 1980 | 1993 |
| 1981 | 1994 |
| 1982 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( | 1995 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
| 1983 Local<Context> v8_context, Source* source, size_t arguments_count, | 1996 Local<Context> v8_context, Source* source, size_t arguments_count, |
| 1984 Local<String> arguments[], size_t context_extension_count, | 1997 Local<String> arguments[], size_t context_extension_count, |
| 1985 Local<Object> context_extensions[]) { | 1998 Local<Object> context_extensions[]) { |
| 1986 PREPARE_FOR_EXECUTION( | 1999 PREPARE_FOR_EXECUTION(v8_context, v8_ScriptCompiler_CompileFunctionInContext, |
| 1987 v8_context, "v8::ScriptCompiler::CompileFunctionInContext()", Function); | 2000 "v8::ScriptCompiler::CompileFunctionInContext", |
| 2001 Function); | |
| 1988 i::Handle<i::String> source_string; | 2002 i::Handle<i::String> source_string; |
| 1989 auto factory = isolate->factory(); | 2003 auto factory = isolate->factory(); |
| 1990 if (arguments_count) { | 2004 if (arguments_count) { |
| 1991 source_string = factory->NewStringFromStaticChars("(function("); | 2005 source_string = factory->NewStringFromStaticChars("(function("); |
| 1992 for (size_t i = 0; i < arguments_count; ++i) { | 2006 for (size_t i = 0; i < arguments_count; ++i) { |
| 1993 IsIdentifierHelper helper; | 2007 IsIdentifierHelper helper; |
| 1994 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { | 2008 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { |
| 1995 return Local<Function>(); | 2009 return Local<Function>(); |
| 1996 } | 2010 } |
| 1997 has_pending_exception = | 2011 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); | 2105 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 2092 return new i::BackgroundParsingTask(source->impl(), options, | 2106 return new i::BackgroundParsingTask(source->impl(), options, |
| 2093 i::FLAG_stack_size, isolate); | 2107 i::FLAG_stack_size, isolate); |
| 2094 } | 2108 } |
| 2095 | 2109 |
| 2096 | 2110 |
| 2097 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, | 2111 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, |
| 2098 StreamedSource* v8_source, | 2112 StreamedSource* v8_source, |
| 2099 Local<String> full_source_string, | 2113 Local<String> full_source_string, |
| 2100 const ScriptOrigin& origin) { | 2114 const ScriptOrigin& origin) { |
| 2101 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); | 2115 PREPARE_FOR_EXECUTION(context, v8_ScriptCompiler_Compile, |
| 2116 "v8::ScriptCompiler::Compile", Script); | |
| 2102 i::StreamedSource* source = v8_source->impl(); | 2117 i::StreamedSource* source = v8_source->impl(); |
| 2103 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); | 2118 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); |
| 2104 i::Handle<i::Script> script = isolate->factory()->NewScript(str); | 2119 i::Handle<i::Script> script = isolate->factory()->NewScript(str); |
| 2105 if (!origin.ResourceName().IsEmpty()) { | 2120 if (!origin.ResourceName().IsEmpty()) { |
| 2106 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 2121 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
| 2107 } | 2122 } |
| 2108 if (!origin.ResourceLineOffset().IsEmpty()) { | 2123 if (!origin.ResourceLineOffset().IsEmpty()) { |
| 2109 script->set_line_offset( | 2124 script->set_line_offset( |
| 2110 static_cast<int>(origin.ResourceLineOffset()->Value())); | 2125 static_cast<int>(origin.ResourceLineOffset()->Value())); |
| 2111 } | 2126 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2290 } else { | 2305 } else { |
| 2291 return v8::Local<Value>(); | 2306 return v8::Local<Value>(); |
| 2292 } | 2307 } |
| 2293 } | 2308 } |
| 2294 | 2309 |
| 2295 | 2310 |
| 2296 MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const { | 2311 MaybeLocal<Value> v8::TryCatch::StackTrace(Local<Context> context) const { |
| 2297 if (!HasCaught()) return v8::Local<Value>(); | 2312 if (!HasCaught()) return v8::Local<Value>(); |
| 2298 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 2313 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
| 2299 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 2314 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
| 2300 PREPARE_FOR_EXECUTION(context, "v8::TryCatch::StackTrace", Value); | 2315 PREPARE_FOR_EXECUTION(context, v8_TryCatch_StackTrace, |
| 2316 "v8::TryCatch::StackTrace", Value); | |
| 2301 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 2317 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
| 2302 i::Handle<i::String> name = isolate->factory()->stack_string(); | 2318 i::Handle<i::String> name = isolate->factory()->stack_string(); |
| 2303 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); | 2319 Maybe<bool> maybe = i::JSReceiver::HasProperty(obj, name); |
| 2304 has_pending_exception = !maybe.IsJust(); | 2320 has_pending_exception = !maybe.IsJust(); |
| 2305 RETURN_ON_FAILED_EXECUTION(Value); | 2321 RETURN_ON_FAILED_EXECUTION(Value); |
| 2306 if (!maybe.FromJust()) return v8::Local<Value>(); | 2322 if (!maybe.FromJust()) return v8::Local<Value>(); |
| 2307 Local<Value> result; | 2323 Local<Value> result; |
| 2308 has_pending_exception = | 2324 has_pending_exception = |
| 2309 !ToLocal<Value>(i::JSReceiver::GetProperty(obj, name), &result); | 2325 !ToLocal<Value>(i::JSReceiver::GetProperty(obj, name), &result); |
| 2310 RETURN_ON_FAILED_EXECUTION(Value); | 2326 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)); | 2408 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2393 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2409 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2394 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2410 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
| 2395 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); | 2411 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); |
| 2396 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); | 2412 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); |
| 2397 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); | 2413 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); |
| 2398 } | 2414 } |
| 2399 | 2415 |
| 2400 | 2416 |
| 2401 Maybe<int> Message::GetLineNumber(Local<Context> context) const { | 2417 Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
| 2402 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetLineNumber()", int); | 2418 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Message_GetLineNumber, |
| 2419 "v8::Message::GetLineNumber", int); | |
| 2403 i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); | 2420 i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); |
| 2404 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2421 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
| 2405 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2422 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
| 2406 i::Handle<i::Object> result; | 2423 i::Handle<i::Object> result; |
| 2407 has_pending_exception = | 2424 has_pending_exception = |
| 2408 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2425 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
| 2409 .ToHandle(&result); | 2426 .ToHandle(&result); |
| 2410 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2427 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
| 2411 return Just(static_cast<int>(result->Number())); | 2428 return Just(static_cast<int>(result->Number())); |
| 2412 } | 2429 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 2424 } | 2441 } |
| 2425 | 2442 |
| 2426 | 2443 |
| 2427 int Message::GetEndPosition() const { | 2444 int Message::GetEndPosition() const { |
| 2428 auto self = Utils::OpenHandle(this); | 2445 auto self = Utils::OpenHandle(this); |
| 2429 return self->end_position(); | 2446 return self->end_position(); |
| 2430 } | 2447 } |
| 2431 | 2448 |
| 2432 | 2449 |
| 2433 Maybe<int> Message::GetStartColumn(Local<Context> context) const { | 2450 Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
| 2434 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetStartColumn()", | 2451 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Message_GetStartColumn, |
| 2435 int); | 2452 "v8::Message::GetStartColumn", int); |
| 2436 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2453 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
| 2437 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2454 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
| 2438 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2455 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
| 2439 i::Handle<i::Object> result; | 2456 i::Handle<i::Object> result; |
| 2440 has_pending_exception = | 2457 has_pending_exception = |
| 2441 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2458 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
| 2442 .ToHandle(&result); | 2459 .ToHandle(&result); |
| 2443 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2460 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
| 2444 return Just(static_cast<int>(result->Number())); | 2461 return Just(static_cast<int>(result->Number())); |
| 2445 } | 2462 } |
| 2446 | 2463 |
| 2447 | 2464 |
| 2448 int Message::GetStartColumn() const { | 2465 int Message::GetStartColumn() const { |
| 2449 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 2466 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 2450 const int default_value = kNoColumnInfo; | 2467 const int default_value = kNoColumnInfo; |
| 2451 return GetStartColumn(context).FromMaybe(default_value); | 2468 return GetStartColumn(context).FromMaybe(default_value); |
| 2452 } | 2469 } |
| 2453 | 2470 |
| 2454 | 2471 |
| 2455 Maybe<int> Message::GetEndColumn(Local<Context> context) const { | 2472 Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
| 2456 auto self = Utils::OpenHandle(this); | 2473 auto self = Utils::OpenHandle(this); |
| 2457 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Message::GetEndColumn()", int); | 2474 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Message_GetEndColumn, |
| 2475 "v8::Message::GetEndColumn", int); | |
| 2458 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); | 2476 i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
| 2459 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2477 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
| 2460 i::Handle<i::Object> args[] = {self}; | 2478 i::Handle<i::Object> args[] = {self}; |
| 2461 i::Handle<i::Object> result; | 2479 i::Handle<i::Object> result; |
| 2462 has_pending_exception = | 2480 has_pending_exception = |
| 2463 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2481 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
| 2464 .ToHandle(&result); | 2482 .ToHandle(&result); |
| 2465 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); | 2483 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
| 2466 int start = self->start_position(); | 2484 int start = self->start_position(); |
| 2467 int end = self->end_position(); | 2485 int end = self->end_position(); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 2491 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2509 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2492 ENTER_V8(isolate); | 2510 ENTER_V8(isolate); |
| 2493 auto self = Utils::OpenHandle(this); | 2511 auto self = Utils::OpenHandle(this); |
| 2494 auto script = i::Handle<i::JSValue>::cast( | 2512 auto script = i::Handle<i::JSValue>::cast( |
| 2495 i::Handle<i::Object>(self->script(), isolate)); | 2513 i::Handle<i::Object>(self->script(), isolate)); |
| 2496 return i::Script::cast(script->value())->origin_options().IsOpaque(); | 2514 return i::Script::cast(script->value())->origin_options().IsOpaque(); |
| 2497 } | 2515 } |
| 2498 | 2516 |
| 2499 | 2517 |
| 2500 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { | 2518 MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
| 2501 PREPARE_FOR_EXECUTION(context, "v8::Message::GetSourceLine()", String); | 2519 PREPARE_FOR_EXECUTION(context, v8_Message_GetSourceLine, |
| 2520 "v8::Message::GetSourceLine", String); | |
| 2502 i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); | 2521 i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); |
| 2503 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); | 2522 i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
| 2504 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; | 2523 i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
| 2505 i::Handle<i::Object> result; | 2524 i::Handle<i::Object> result; |
| 2506 has_pending_exception = | 2525 has_pending_exception = |
| 2507 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) | 2526 !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
| 2508 .ToHandle(&result); | 2527 .ToHandle(&result); |
| 2509 RETURN_ON_FAILED_EXECUTION(String); | 2528 RETURN_ON_FAILED_EXECUTION(String); |
| 2510 Local<String> str; | 2529 Local<String> str; |
| 2511 if (result->IsString()) { | 2530 if (result->IsString()) { |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2736 } | 2755 } |
| 2737 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); | 2756 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); |
| 2738 return i::JSWeakCollection::Delete(weak_collection, key, hash); | 2757 return i::JSWeakCollection::Delete(weak_collection, key, hash); |
| 2739 } | 2758 } |
| 2740 | 2759 |
| 2741 | 2760 |
| 2742 // --- J S O N --- | 2761 // --- J S O N --- |
| 2743 | 2762 |
| 2744 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { | 2763 MaybeLocal<Value> JSON::Parse(Isolate* v8_isolate, Local<String> json_string) { |
| 2745 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2764 auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 2746 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Parse", Value); | 2765 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, JSON_Parse, "JSON::Parse", Value); |
| 2747 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2766 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
| 2748 i::Handle<i::String> source = i::String::Flatten(string); | 2767 i::Handle<i::String> source = i::String::Flatten(string); |
| 2749 auto maybe = source->IsSeqOneByteString() | 2768 auto maybe = source->IsSeqOneByteString() |
| 2750 ? i::JsonParser<true>::Parse(source) | 2769 ? i::JsonParser<true>::Parse(source) |
| 2751 : i::JsonParser<false>::Parse(source); | 2770 : i::JsonParser<false>::Parse(source); |
| 2752 Local<Value> result; | 2771 Local<Value> result; |
| 2753 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2772 has_pending_exception = !ToLocal<Value>(maybe, &result); |
| 2754 RETURN_ON_FAILED_EXECUTION(Value); | 2773 RETURN_ON_FAILED_EXECUTION(Value); |
| 2755 RETURN_ESCAPED(result); | 2774 RETURN_ESCAPED(result); |
| 2756 } | 2775 } |
| 2757 | 2776 |
| 2758 MaybeLocal<Value> JSON::Parse(Local<Context> context, | 2777 MaybeLocal<Value> JSON::Parse(Local<Context> context, |
| 2759 Local<String> json_string) { | 2778 Local<String> json_string) { |
| 2760 PREPARE_FOR_EXECUTION(context, "JSON::Parse", Value); | 2779 PREPARE_FOR_EXECUTION(context, JSON_Parse, "JSON::Parse", Value); |
| 2761 i::Handle<i::String> string = Utils::OpenHandle(*json_string); | 2780 i::Handle<i::String> string = Utils::OpenHandle(*json_string); |
| 2762 i::Handle<i::String> source = i::String::Flatten(string); | 2781 i::Handle<i::String> source = i::String::Flatten(string); |
| 2763 auto maybe = source->IsSeqOneByteString() | 2782 auto maybe = source->IsSeqOneByteString() |
| 2764 ? i::JsonParser<true>::Parse(source) | 2783 ? i::JsonParser<true>::Parse(source) |
| 2765 : i::JsonParser<false>::Parse(source); | 2784 : i::JsonParser<false>::Parse(source); |
| 2766 Local<Value> result; | 2785 Local<Value> result; |
| 2767 has_pending_exception = !ToLocal<Value>(maybe, &result); | 2786 has_pending_exception = !ToLocal<Value>(maybe, &result); |
| 2768 RETURN_ON_FAILED_EXECUTION(Value); | 2787 RETURN_ON_FAILED_EXECUTION(Value); |
| 2769 RETURN_ESCAPED(result); | 2788 RETURN_ESCAPED(result); |
| 2770 } | 2789 } |
| 2771 | 2790 |
| 2772 Local<Value> JSON::Parse(Local<String> json_string) { | 2791 Local<Value> JSON::Parse(Local<String> json_string) { |
| 2773 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); | 2792 RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value); |
| 2774 } | 2793 } |
| 2775 | 2794 |
| 2776 MaybeLocal<String> JSON::Stringify(Local<Context> context, | 2795 MaybeLocal<String> JSON::Stringify(Local<Context> context, |
| 2777 Local<Object> json_object) { | 2796 Local<Object> json_object) { |
| 2778 PREPARE_FOR_EXECUTION(context, "JSON::Stringify", String); | 2797 PREPARE_FOR_EXECUTION(context, JSON_Stringify, "JSON::Stringify", String); |
| 2779 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); | 2798 i::Handle<i::Object> object = Utils::OpenHandle(*json_object); |
| 2780 i::Handle<i::Object> maybe; | 2799 i::Handle<i::Object> maybe; |
| 2781 has_pending_exception = | 2800 has_pending_exception = |
| 2782 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); | 2801 !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe); |
| 2783 RETURN_ON_FAILED_EXECUTION(String); | 2802 RETURN_ON_FAILED_EXECUTION(String); |
| 2784 Local<String> result; | 2803 Local<String> result; |
| 2785 has_pending_exception = | 2804 has_pending_exception = |
| 2786 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); | 2805 !ToLocal<String>(i::Object::ToString(isolate, maybe), &result); |
| 2787 RETURN_ON_FAILED_EXECUTION(String); | 2806 RETURN_ON_FAILED_EXECUTION(String); |
| 2788 RETURN_ESCAPED(result); | 2807 RETURN_ESCAPED(result); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2997 | 3016 |
| 2998 bool Value::IsPromise() const { | 3017 bool Value::IsPromise() const { |
| 2999 auto self = Utils::OpenHandle(this); | 3018 auto self = Utils::OpenHandle(this); |
| 3000 return i::Object::IsPromise(self); | 3019 return i::Object::IsPromise(self); |
| 3001 } | 3020 } |
| 3002 | 3021 |
| 3003 | 3022 |
| 3004 MaybeLocal<String> Value::ToString(Local<Context> context) const { | 3023 MaybeLocal<String> Value::ToString(Local<Context> context) const { |
| 3005 auto obj = Utils::OpenHandle(this); | 3024 auto obj = Utils::OpenHandle(this); |
| 3006 if (obj->IsString()) return ToApiHandle<String>(obj); | 3025 if (obj->IsString()) return ToApiHandle<String>(obj); |
| 3007 PREPARE_FOR_EXECUTION(context, "ToString", String); | 3026 PREPARE_FOR_EXECUTION(context, ToString, "ToString", String); |
| 3008 Local<String> result; | 3027 Local<String> result; |
| 3009 has_pending_exception = | 3028 has_pending_exception = |
| 3010 !ToLocal<String>(i::Object::ToString(isolate, obj), &result); | 3029 !ToLocal<String>(i::Object::ToString(isolate, obj), &result); |
| 3011 RETURN_ON_FAILED_EXECUTION(String); | 3030 RETURN_ON_FAILED_EXECUTION(String); |
| 3012 RETURN_ESCAPED(result); | 3031 RETURN_ESCAPED(result); |
| 3013 } | 3032 } |
| 3014 | 3033 |
| 3015 | 3034 |
| 3016 Local<String> Value::ToString(Isolate* isolate) const { | 3035 Local<String> Value::ToString(Isolate* isolate) const { |
| 3017 RETURN_TO_LOCAL_UNCHECKED(ToString(isolate->GetCurrentContext()), String); | 3036 RETURN_TO_LOCAL_UNCHECKED(ToString(isolate->GetCurrentContext()), String); |
| 3018 } | 3037 } |
| 3019 | 3038 |
| 3020 | 3039 |
| 3021 MaybeLocal<String> Value::ToDetailString(Local<Context> context) const { | 3040 MaybeLocal<String> Value::ToDetailString(Local<Context> context) const { |
| 3022 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3041 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 3023 if (obj->IsString()) return ToApiHandle<String>(obj); | 3042 if (obj->IsString()) return ToApiHandle<String>(obj); |
| 3024 PREPARE_FOR_EXECUTION(context, "ToDetailString", String); | 3043 PREPARE_FOR_EXECUTION(context, ToDetailString, "ToDetailString", String); |
| 3025 Local<String> result; | 3044 Local<String> result; |
| 3026 i::Handle<i::Object> args[] = {obj}; | 3045 i::Handle<i::Object> args[] = {obj}; |
| 3027 has_pending_exception = !ToLocal<String>( | 3046 has_pending_exception = !ToLocal<String>( |
| 3028 i::Execution::TryCall(isolate, isolate->no_side_effects_to_string_fun(), | 3047 i::Execution::TryCall(isolate, isolate->no_side_effects_to_string_fun(), |
| 3029 isolate->factory()->undefined_value(), | 3048 isolate->factory()->undefined_value(), |
| 3030 arraysize(args), args), | 3049 arraysize(args), args), |
| 3031 &result); | 3050 &result); |
| 3032 RETURN_ON_FAILED_EXECUTION(String); | 3051 RETURN_ON_FAILED_EXECUTION(String); |
| 3033 RETURN_ESCAPED(result); | 3052 RETURN_ESCAPED(result); |
| 3034 } | 3053 } |
| 3035 | 3054 |
| 3036 | 3055 |
| 3037 Local<String> Value::ToDetailString(Isolate* isolate) const { | 3056 Local<String> Value::ToDetailString(Isolate* isolate) const { |
| 3038 RETURN_TO_LOCAL_UNCHECKED(ToDetailString(isolate->GetCurrentContext()), | 3057 RETURN_TO_LOCAL_UNCHECKED(ToDetailString(isolate->GetCurrentContext()), |
| 3039 String); | 3058 String); |
| 3040 } | 3059 } |
| 3041 | 3060 |
| 3042 | 3061 |
| 3043 MaybeLocal<Object> Value::ToObject(Local<Context> context) const { | 3062 MaybeLocal<Object> Value::ToObject(Local<Context> context) const { |
| 3044 auto obj = Utils::OpenHandle(this); | 3063 auto obj = Utils::OpenHandle(this); |
| 3045 if (obj->IsJSReceiver()) return ToApiHandle<Object>(obj); | 3064 if (obj->IsJSReceiver()) return ToApiHandle<Object>(obj); |
| 3046 PREPARE_FOR_EXECUTION(context, "ToObject", Object); | 3065 PREPARE_FOR_EXECUTION(context, ToObject, "ToObject", Object); |
| 3047 Local<Object> result; | 3066 Local<Object> result; |
| 3048 has_pending_exception = | 3067 has_pending_exception = |
| 3049 !ToLocal<Object>(i::Object::ToObject(isolate, obj), &result); | 3068 !ToLocal<Object>(i::Object::ToObject(isolate, obj), &result); |
| 3050 RETURN_ON_FAILED_EXECUTION(Object); | 3069 RETURN_ON_FAILED_EXECUTION(Object); |
| 3051 RETURN_ESCAPED(result); | 3070 RETURN_ESCAPED(result); |
| 3052 } | 3071 } |
| 3053 | 3072 |
| 3054 | 3073 |
| 3055 Local<v8::Object> Value::ToObject(Isolate* isolate) const { | 3074 Local<v8::Object> Value::ToObject(Isolate* isolate) const { |
| 3056 RETURN_TO_LOCAL_UNCHECKED(ToObject(isolate->GetCurrentContext()), Object); | 3075 RETURN_TO_LOCAL_UNCHECKED(ToObject(isolate->GetCurrentContext()), Object); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3067 | 3086 |
| 3068 | 3087 |
| 3069 Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const { | 3088 Local<Boolean> Value::ToBoolean(Isolate* v8_isolate) const { |
| 3070 return ToBoolean(v8_isolate->GetCurrentContext()).ToLocalChecked(); | 3089 return ToBoolean(v8_isolate->GetCurrentContext()).ToLocalChecked(); |
| 3071 } | 3090 } |
| 3072 | 3091 |
| 3073 | 3092 |
| 3074 MaybeLocal<Number> Value::ToNumber(Local<Context> context) const { | 3093 MaybeLocal<Number> Value::ToNumber(Local<Context> context) const { |
| 3075 auto obj = Utils::OpenHandle(this); | 3094 auto obj = Utils::OpenHandle(this); |
| 3076 if (obj->IsNumber()) return ToApiHandle<Number>(obj); | 3095 if (obj->IsNumber()) return ToApiHandle<Number>(obj); |
| 3077 PREPARE_FOR_EXECUTION(context, "ToNumber", Number); | 3096 PREPARE_FOR_EXECUTION(context, ToNumber, "ToNumber", Number); |
| 3078 Local<Number> result; | 3097 Local<Number> result; |
| 3079 has_pending_exception = !ToLocal<Number>(i::Object::ToNumber(obj), &result); | 3098 has_pending_exception = !ToLocal<Number>(i::Object::ToNumber(obj), &result); |
| 3080 RETURN_ON_FAILED_EXECUTION(Number); | 3099 RETURN_ON_FAILED_EXECUTION(Number); |
| 3081 RETURN_ESCAPED(result); | 3100 RETURN_ESCAPED(result); |
| 3082 } | 3101 } |
| 3083 | 3102 |
| 3084 | 3103 |
| 3085 Local<Number> Value::ToNumber(Isolate* isolate) const { | 3104 Local<Number> Value::ToNumber(Isolate* isolate) const { |
| 3086 RETURN_TO_LOCAL_UNCHECKED(ToNumber(isolate->GetCurrentContext()), Number); | 3105 RETURN_TO_LOCAL_UNCHECKED(ToNumber(isolate->GetCurrentContext()), Number); |
| 3087 } | 3106 } |
| 3088 | 3107 |
| 3089 | 3108 |
| 3090 MaybeLocal<Integer> Value::ToInteger(Local<Context> context) const { | 3109 MaybeLocal<Integer> Value::ToInteger(Local<Context> context) const { |
| 3091 auto obj = Utils::OpenHandle(this); | 3110 auto obj = Utils::OpenHandle(this); |
| 3092 if (obj->IsSmi()) return ToApiHandle<Integer>(obj); | 3111 if (obj->IsSmi()) return ToApiHandle<Integer>(obj); |
| 3093 PREPARE_FOR_EXECUTION(context, "ToInteger", Integer); | 3112 PREPARE_FOR_EXECUTION(context, ToInteger, "ToInteger", Integer); |
| 3094 Local<Integer> result; | 3113 Local<Integer> result; |
| 3095 has_pending_exception = | 3114 has_pending_exception = |
| 3096 !ToLocal<Integer>(i::Object::ToInteger(isolate, obj), &result); | 3115 !ToLocal<Integer>(i::Object::ToInteger(isolate, obj), &result); |
| 3097 RETURN_ON_FAILED_EXECUTION(Integer); | 3116 RETURN_ON_FAILED_EXECUTION(Integer); |
| 3098 RETURN_ESCAPED(result); | 3117 RETURN_ESCAPED(result); |
| 3099 } | 3118 } |
| 3100 | 3119 |
| 3101 | 3120 |
| 3102 Local<Integer> Value::ToInteger(Isolate* isolate) const { | 3121 Local<Integer> Value::ToInteger(Isolate* isolate) const { |
| 3103 RETURN_TO_LOCAL_UNCHECKED(ToInteger(isolate->GetCurrentContext()), Integer); | 3122 RETURN_TO_LOCAL_UNCHECKED(ToInteger(isolate->GetCurrentContext()), Integer); |
| 3104 } | 3123 } |
| 3105 | 3124 |
| 3106 | 3125 |
| 3107 MaybeLocal<Int32> Value::ToInt32(Local<Context> context) const { | 3126 MaybeLocal<Int32> Value::ToInt32(Local<Context> context) const { |
| 3108 auto obj = Utils::OpenHandle(this); | 3127 auto obj = Utils::OpenHandle(this); |
| 3109 if (obj->IsSmi()) return ToApiHandle<Int32>(obj); | 3128 if (obj->IsSmi()) return ToApiHandle<Int32>(obj); |
| 3110 Local<Int32> result; | 3129 Local<Int32> result; |
| 3111 PREPARE_FOR_EXECUTION(context, "ToInt32", Int32); | 3130 PREPARE_FOR_EXECUTION(context, ToInt32, "ToInt32", Int32); |
| 3112 has_pending_exception = | 3131 has_pending_exception = |
| 3113 !ToLocal<Int32>(i::Object::ToInt32(isolate, obj), &result); | 3132 !ToLocal<Int32>(i::Object::ToInt32(isolate, obj), &result); |
| 3114 RETURN_ON_FAILED_EXECUTION(Int32); | 3133 RETURN_ON_FAILED_EXECUTION(Int32); |
| 3115 RETURN_ESCAPED(result); | 3134 RETURN_ESCAPED(result); |
| 3116 } | 3135 } |
| 3117 | 3136 |
| 3118 | 3137 |
| 3119 Local<Int32> Value::ToInt32(Isolate* isolate) const { | 3138 Local<Int32> Value::ToInt32(Isolate* isolate) const { |
| 3120 RETURN_TO_LOCAL_UNCHECKED(ToInt32(isolate->GetCurrentContext()), Int32); | 3139 RETURN_TO_LOCAL_UNCHECKED(ToInt32(isolate->GetCurrentContext()), Int32); |
| 3121 } | 3140 } |
| 3122 | 3141 |
| 3123 | 3142 |
| 3124 MaybeLocal<Uint32> Value::ToUint32(Local<Context> context) const { | 3143 MaybeLocal<Uint32> Value::ToUint32(Local<Context> context) const { |
| 3125 auto obj = Utils::OpenHandle(this); | 3144 auto obj = Utils::OpenHandle(this); |
| 3126 if (obj->IsSmi()) return ToApiHandle<Uint32>(obj); | 3145 if (obj->IsSmi()) return ToApiHandle<Uint32>(obj); |
| 3127 Local<Uint32> result; | 3146 Local<Uint32> result; |
| 3128 PREPARE_FOR_EXECUTION(context, "ToUint32", Uint32); | 3147 PREPARE_FOR_EXECUTION(context, ToUint32, "ToUint32", Uint32); |
| 3129 has_pending_exception = | 3148 has_pending_exception = |
| 3130 !ToLocal<Uint32>(i::Object::ToUint32(isolate, obj), &result); | 3149 !ToLocal<Uint32>(i::Object::ToUint32(isolate, obj), &result); |
| 3131 RETURN_ON_FAILED_EXECUTION(Uint32); | 3150 RETURN_ON_FAILED_EXECUTION(Uint32); |
| 3132 RETURN_ESCAPED(result); | 3151 RETURN_ESCAPED(result); |
| 3133 } | 3152 } |
| 3134 | 3153 |
| 3135 | 3154 |
| 3136 Local<Uint32> Value::ToUint32(Isolate* isolate) const { | 3155 Local<Uint32> Value::ToUint32(Isolate* isolate) const { |
| 3137 RETURN_TO_LOCAL_UNCHECKED(ToUint32(isolate->GetCurrentContext()), Uint32); | 3156 RETURN_TO_LOCAL_UNCHECKED(ToUint32(isolate->GetCurrentContext()), Uint32); |
| 3138 } | 3157 } |
| 3139 | 3158 |
| 3140 | 3159 |
| 3141 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { | 3160 void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) { |
| 3142 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 3161 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
| 3143 Utils::ApiCheck(isolate != NULL && | 3162 Utils::ApiCheck(isolate != NULL && !isolate->IsDead(), |
| 3144 !isolate->IsDead(), | 3163 "v8::internal::Internals::CheckInitialized", |
| 3145 "v8::internal::Internals::CheckInitialized()", | |
| 3146 "Isolate is not initialized or V8 has died"); | 3164 "Isolate is not initialized or V8 has died"); |
| 3147 } | 3165 } |
| 3148 | 3166 |
| 3149 | 3167 |
| 3150 void External::CheckCast(v8::Value* that) { | 3168 void External::CheckCast(v8::Value* that) { |
| 3151 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), | 3169 Utils::ApiCheck(Utils::OpenHandle(that)->IsExternal(), "v8::External::Cast", |
| 3152 "v8::External::Cast()", | |
| 3153 "Could not convert to external"); | 3170 "Could not convert to external"); |
| 3154 } | 3171 } |
| 3155 | 3172 |
| 3156 | 3173 |
| 3157 void v8::Object::CheckCast(Value* that) { | 3174 void v8::Object::CheckCast(Value* that) { |
| 3158 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3175 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3159 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast()", | 3176 Utils::ApiCheck(obj->IsJSReceiver(), "v8::Object::Cast", |
| 3160 "Could not convert to object"); | 3177 "Could not convert to object"); |
| 3161 } | 3178 } |
| 3162 | 3179 |
| 3163 | 3180 |
| 3164 void v8::Function::CheckCast(Value* that) { | 3181 void v8::Function::CheckCast(Value* that) { |
| 3165 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3182 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3166 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast()", | 3183 Utils::ApiCheck(obj->IsCallable(), "v8::Function::Cast", |
| 3167 "Could not convert to function"); | 3184 "Could not convert to function"); |
| 3168 } | 3185 } |
| 3169 | 3186 |
| 3170 | 3187 |
| 3171 void v8::Boolean::CheckCast(v8::Value* that) { | 3188 void v8::Boolean::CheckCast(v8::Value* that) { |
| 3172 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3189 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3173 Utils::ApiCheck(obj->IsBoolean(), | 3190 Utils::ApiCheck(obj->IsBoolean(), "v8::Boolean::Cast", |
| 3174 "v8::Boolean::Cast()", | |
| 3175 "Could not convert to boolean"); | 3191 "Could not convert to boolean"); |
| 3176 } | 3192 } |
| 3177 | 3193 |
| 3178 | 3194 |
| 3179 void v8::Name::CheckCast(v8::Value* that) { | 3195 void v8::Name::CheckCast(v8::Value* that) { |
| 3180 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3196 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3181 Utils::ApiCheck(obj->IsName(), | 3197 Utils::ApiCheck(obj->IsName(), "v8::Name::Cast", "Could not convert to name"); |
| 3182 "v8::Name::Cast()", | |
| 3183 "Could not convert to name"); | |
| 3184 } | 3198 } |
| 3185 | 3199 |
| 3186 | 3200 |
| 3187 void v8::String::CheckCast(v8::Value* that) { | 3201 void v8::String::CheckCast(v8::Value* that) { |
| 3188 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3202 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3189 Utils::ApiCheck(obj->IsString(), | 3203 Utils::ApiCheck(obj->IsString(), "v8::String::Cast", |
| 3190 "v8::String::Cast()", | |
| 3191 "Could not convert to string"); | 3204 "Could not convert to string"); |
| 3192 } | 3205 } |
| 3193 | 3206 |
| 3194 | 3207 |
| 3195 void v8::Symbol::CheckCast(v8::Value* that) { | 3208 void v8::Symbol::CheckCast(v8::Value* that) { |
| 3196 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3209 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3197 Utils::ApiCheck(obj->IsSymbol(), | 3210 Utils::ApiCheck(obj->IsSymbol(), "v8::Symbol::Cast", |
| 3198 "v8::Symbol::Cast()", | |
| 3199 "Could not convert to symbol"); | 3211 "Could not convert to symbol"); |
| 3200 } | 3212 } |
| 3201 | 3213 |
| 3202 | 3214 |
| 3203 void v8::Number::CheckCast(v8::Value* that) { | 3215 void v8::Number::CheckCast(v8::Value* that) { |
| 3204 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3216 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3205 Utils::ApiCheck(obj->IsNumber(), | 3217 Utils::ApiCheck(obj->IsNumber(), |
| 3206 "v8::Number::Cast()", | 3218 "v8::Number::Cast()", |
| 3207 "Could not convert to number"); | 3219 "Could not convert to number"); |
| 3208 } | 3220 } |
| 3209 | 3221 |
| 3210 | 3222 |
| 3211 void v8::Integer::CheckCast(v8::Value* that) { | 3223 void v8::Integer::CheckCast(v8::Value* that) { |
| 3212 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3224 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3213 Utils::ApiCheck(obj->IsNumber(), | 3225 Utils::ApiCheck(obj->IsNumber(), "v8::Integer::Cast", |
| 3214 "v8::Integer::Cast()", | |
| 3215 "Could not convert to number"); | 3226 "Could not convert to number"); |
| 3216 } | 3227 } |
| 3217 | 3228 |
| 3218 | 3229 |
| 3219 void v8::Int32::CheckCast(v8::Value* that) { | 3230 void v8::Int32::CheckCast(v8::Value* that) { |
| 3220 Utils::ApiCheck(that->IsInt32(), "v8::Int32::Cast()", | 3231 Utils::ApiCheck(that->IsInt32(), "v8::Int32::Cast", |
| 3221 "Could not convert to 32-bit signed integer"); | 3232 "Could not convert to 32-bit signed integer"); |
| 3222 } | 3233 } |
| 3223 | 3234 |
| 3224 | 3235 |
| 3225 void v8::Uint32::CheckCast(v8::Value* that) { | 3236 void v8::Uint32::CheckCast(v8::Value* that) { |
| 3226 Utils::ApiCheck(that->IsUint32(), "v8::Uint32::Cast()", | 3237 Utils::ApiCheck(that->IsUint32(), "v8::Uint32::Cast", |
| 3227 "Could not convert to 32-bit unsigned integer"); | 3238 "Could not convert to 32-bit unsigned integer"); |
| 3228 } | 3239 } |
| 3229 | 3240 |
| 3230 | 3241 |
| 3231 void v8::Array::CheckCast(Value* that) { | 3242 void v8::Array::CheckCast(Value* that) { |
| 3232 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3243 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3233 Utils::ApiCheck(obj->IsJSArray(), | 3244 Utils::ApiCheck(obj->IsJSArray(), "v8::Array::Cast", |
| 3234 "v8::Array::Cast()", | |
| 3235 "Could not convert to array"); | 3245 "Could not convert to array"); |
| 3236 } | 3246 } |
| 3237 | 3247 |
| 3238 | 3248 |
| 3239 void v8::Map::CheckCast(Value* that) { | 3249 void v8::Map::CheckCast(Value* that) { |
| 3240 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3250 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3241 Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast()", | 3251 Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast", "Could not convert to Map"); |
| 3242 "Could not convert to Map"); | |
| 3243 } | 3252 } |
| 3244 | 3253 |
| 3245 | 3254 |
| 3246 void v8::Set::CheckCast(Value* that) { | 3255 void v8::Set::CheckCast(Value* that) { |
| 3247 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3256 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3248 Utils::ApiCheck(obj->IsJSSet(), "v8::Set::Cast()", | 3257 Utils::ApiCheck(obj->IsJSSet(), "v8_Set_Cast", "Could not convert to Set"); |
| 3249 "Could not convert to Set"); | |
| 3250 } | 3258 } |
| 3251 | 3259 |
| 3252 | 3260 |
| 3253 void v8::Promise::CheckCast(Value* that) { | 3261 void v8::Promise::CheckCast(Value* that) { |
| 3254 Utils::ApiCheck(that->IsPromise(), | 3262 Utils::ApiCheck(that->IsPromise(), "v8::Promise::Cast", |
| 3255 "v8::Promise::Cast()", | |
| 3256 "Could not convert to promise"); | 3263 "Could not convert to promise"); |
| 3257 } | 3264 } |
| 3258 | 3265 |
| 3259 | 3266 |
| 3260 void v8::Promise::Resolver::CheckCast(Value* that) { | 3267 void v8::Promise::Resolver::CheckCast(Value* that) { |
| 3261 Utils::ApiCheck(that->IsPromise(), | 3268 Utils::ApiCheck(that->IsPromise(), "v8::Promise::Resolver::Cast", |
| 3262 "v8::Promise::Resolver::Cast()", | |
| 3263 "Could not convert to promise resolver"); | 3269 "Could not convert to promise resolver"); |
| 3264 } | 3270 } |
| 3265 | 3271 |
| 3266 | 3272 |
| 3267 void v8::Proxy::CheckCast(Value* that) { | 3273 void v8::Proxy::CheckCast(Value* that) { |
| 3268 Utils::ApiCheck(that->IsProxy(), "v8::Proxy::Cast()", | 3274 Utils::ApiCheck(that->IsProxy(), "v8::Proxy::Cast", |
| 3269 "Could not convert to proxy"); | 3275 "Could not convert to proxy"); |
| 3270 } | 3276 } |
| 3271 | 3277 |
| 3272 | 3278 |
| 3273 void v8::ArrayBuffer::CheckCast(Value* that) { | 3279 void v8::ArrayBuffer::CheckCast(Value* that) { |
| 3274 i::Handle<i::Object> obj = Utils::OpenHandle(that); | 3280 i::Handle<i::Object> obj = Utils::OpenHandle(that); |
| 3275 Utils::ApiCheck( | 3281 Utils::ApiCheck( |
| 3276 obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(), | 3282 obj->IsJSArrayBuffer() && !i::JSArrayBuffer::cast(*obj)->is_shared(), |
| 3277 "v8::ArrayBuffer::Cast()", "Could not convert to ArrayBuffer"); | 3283 "v8::ArrayBuffer::Cast()", "Could not convert to ArrayBuffer"); |
| 3278 } | 3284 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3395 | 3401 |
| 3396 | 3402 |
| 3397 bool Value::BooleanValue() const { | 3403 bool Value::BooleanValue() const { |
| 3398 return Utils::OpenHandle(this)->BooleanValue(); | 3404 return Utils::OpenHandle(this)->BooleanValue(); |
| 3399 } | 3405 } |
| 3400 | 3406 |
| 3401 | 3407 |
| 3402 Maybe<double> Value::NumberValue(Local<Context> context) const { | 3408 Maybe<double> Value::NumberValue(Local<Context> context) const { |
| 3403 auto obj = Utils::OpenHandle(this); | 3409 auto obj = Utils::OpenHandle(this); |
| 3404 if (obj->IsNumber()) return Just(obj->Number()); | 3410 if (obj->IsNumber()) return Just(obj->Number()); |
| 3405 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "NumberValue", double); | 3411 PREPARE_FOR_EXECUTION_PRIMITIVE(context, NumberValue, "NumberValue", double); |
| 3406 i::Handle<i::Object> num; | 3412 i::Handle<i::Object> num; |
| 3407 has_pending_exception = !i::Object::ToNumber(obj).ToHandle(&num); | 3413 has_pending_exception = !i::Object::ToNumber(obj).ToHandle(&num); |
| 3408 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(double); | 3414 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(double); |
| 3409 return Just(num->Number()); | 3415 return Just(num->Number()); |
| 3410 } | 3416 } |
| 3411 | 3417 |
| 3412 | 3418 |
| 3413 double Value::NumberValue() const { | 3419 double Value::NumberValue() const { |
| 3414 auto obj = Utils::OpenHandle(this); | 3420 auto obj = Utils::OpenHandle(this); |
| 3415 if (obj->IsNumber()) return obj->Number(); | 3421 if (obj->IsNumber()) return obj->Number(); |
| 3416 return NumberValue(ContextFromHeapObject(obj)) | 3422 return NumberValue(ContextFromHeapObject(obj)) |
| 3417 .FromMaybe(std::numeric_limits<double>::quiet_NaN()); | 3423 .FromMaybe(std::numeric_limits<double>::quiet_NaN()); |
| 3418 } | 3424 } |
| 3419 | 3425 |
| 3420 | 3426 |
| 3421 Maybe<int64_t> Value::IntegerValue(Local<Context> context) const { | 3427 Maybe<int64_t> Value::IntegerValue(Local<Context> context) const { |
| 3422 auto obj = Utils::OpenHandle(this); | 3428 auto obj = Utils::OpenHandle(this); |
| 3423 if (obj->IsNumber()) { | 3429 if (obj->IsNumber()) { |
| 3424 return Just(NumberToInt64(*obj)); | 3430 return Just(NumberToInt64(*obj)); |
| 3425 } | 3431 } |
| 3426 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "IntegerValue", int64_t); | 3432 PREPARE_FOR_EXECUTION_PRIMITIVE(context, IntegerValue, "IntegerValue", |
| 3433 int64_t); | |
| 3427 i::Handle<i::Object> num; | 3434 i::Handle<i::Object> num; |
| 3428 has_pending_exception = !i::Object::ToInteger(isolate, obj).ToHandle(&num); | 3435 has_pending_exception = !i::Object::ToInteger(isolate, obj).ToHandle(&num); |
| 3429 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t); | 3436 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int64_t); |
| 3430 return Just(NumberToInt64(*num)); | 3437 return Just(NumberToInt64(*num)); |
| 3431 } | 3438 } |
| 3432 | 3439 |
| 3433 | 3440 |
| 3434 int64_t Value::IntegerValue() const { | 3441 int64_t Value::IntegerValue() const { |
| 3435 auto obj = Utils::OpenHandle(this); | 3442 auto obj = Utils::OpenHandle(this); |
| 3436 if (obj->IsNumber()) { | 3443 if (obj->IsNumber()) { |
| 3437 if (obj->IsSmi()) { | 3444 if (obj->IsSmi()) { |
| 3438 return i::Smi::cast(*obj)->value(); | 3445 return i::Smi::cast(*obj)->value(); |
| 3439 } else { | 3446 } else { |
| 3440 return static_cast<int64_t>(obj->Number()); | 3447 return static_cast<int64_t>(obj->Number()); |
| 3441 } | 3448 } |
| 3442 } | 3449 } |
| 3443 return IntegerValue(ContextFromHeapObject(obj)).FromMaybe(0); | 3450 return IntegerValue(ContextFromHeapObject(obj)).FromMaybe(0); |
| 3444 } | 3451 } |
| 3445 | 3452 |
| 3446 | 3453 |
| 3447 Maybe<int32_t> Value::Int32Value(Local<Context> context) const { | 3454 Maybe<int32_t> Value::Int32Value(Local<Context> context) const { |
| 3448 auto obj = Utils::OpenHandle(this); | 3455 auto obj = Utils::OpenHandle(this); |
| 3449 if (obj->IsNumber()) return Just(NumberToInt32(*obj)); | 3456 if (obj->IsNumber()) return Just(NumberToInt32(*obj)); |
| 3450 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Int32Value", int32_t); | 3457 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Int32Value, "Int32Value", int32_t); |
| 3451 i::Handle<i::Object> num; | 3458 i::Handle<i::Object> num; |
| 3452 has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num); | 3459 has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num); |
| 3453 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t); | 3460 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t); |
| 3454 return Just(num->IsSmi() ? i::Smi::cast(*num)->value() | 3461 return Just(num->IsSmi() ? i::Smi::cast(*num)->value() |
| 3455 : static_cast<int32_t>(num->Number())); | 3462 : static_cast<int32_t>(num->Number())); |
| 3456 } | 3463 } |
| 3457 | 3464 |
| 3458 | 3465 |
| 3459 int32_t Value::Int32Value() const { | 3466 int32_t Value::Int32Value() const { |
| 3460 auto obj = Utils::OpenHandle(this); | 3467 auto obj = Utils::OpenHandle(this); |
| 3461 if (obj->IsNumber()) return NumberToInt32(*obj); | 3468 if (obj->IsNumber()) return NumberToInt32(*obj); |
| 3462 return Int32Value(ContextFromHeapObject(obj)).FromMaybe(0); | 3469 return Int32Value(ContextFromHeapObject(obj)).FromMaybe(0); |
| 3463 } | 3470 } |
| 3464 | 3471 |
| 3465 | 3472 |
| 3466 Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const { | 3473 Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const { |
| 3467 auto obj = Utils::OpenHandle(this); | 3474 auto obj = Utils::OpenHandle(this); |
| 3468 if (obj->IsNumber()) return Just(NumberToUint32(*obj)); | 3475 if (obj->IsNumber()) return Just(NumberToUint32(*obj)); |
| 3469 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Uint32Value", uint32_t); | 3476 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Uint32Value, "Uint32Value", |
| 3477 uint32_t); | |
| 3470 i::Handle<i::Object> num; | 3478 i::Handle<i::Object> num; |
| 3471 has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num); | 3479 has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num); |
| 3472 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t); | 3480 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t); |
| 3473 return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value()) | 3481 return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value()) |
| 3474 : static_cast<uint32_t>(num->Number())); | 3482 : static_cast<uint32_t>(num->Number())); |
| 3475 } | 3483 } |
| 3476 | 3484 |
| 3477 | 3485 |
| 3478 uint32_t Value::Uint32Value() const { | 3486 uint32_t Value::Uint32Value() const { |
| 3479 auto obj = Utils::OpenHandle(this); | 3487 auto obj = Utils::OpenHandle(this); |
| 3480 if (obj->IsNumber()) return NumberToUint32(*obj); | 3488 if (obj->IsNumber()) return NumberToUint32(*obj); |
| 3481 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0); | 3489 return Uint32Value(ContextFromHeapObject(obj)).FromMaybe(0); |
| 3482 } | 3490 } |
| 3483 | 3491 |
| 3484 | 3492 |
| 3485 MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const { | 3493 MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const { |
| 3486 auto self = Utils::OpenHandle(this); | 3494 auto self = Utils::OpenHandle(this); |
| 3487 if (self->IsSmi()) { | 3495 if (self->IsSmi()) { |
| 3488 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); | 3496 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); |
| 3489 return Local<Uint32>(); | 3497 return Local<Uint32>(); |
| 3490 } | 3498 } |
| 3491 PREPARE_FOR_EXECUTION(context, "ToArrayIndex", Uint32); | 3499 PREPARE_FOR_EXECUTION(context, ToArrayIndex, "ToArrayIndex", Uint32); |
| 3492 i::Handle<i::Object> string_obj; | 3500 i::Handle<i::Object> string_obj; |
| 3493 has_pending_exception = | 3501 has_pending_exception = |
| 3494 !i::Object::ToString(isolate, self).ToHandle(&string_obj); | 3502 !i::Object::ToString(isolate, self).ToHandle(&string_obj); |
| 3495 RETURN_ON_FAILED_EXECUTION(Uint32); | 3503 RETURN_ON_FAILED_EXECUTION(Uint32); |
| 3496 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); | 3504 i::Handle<i::String> str = i::Handle<i::String>::cast(string_obj); |
| 3497 uint32_t index; | 3505 uint32_t index; |
| 3498 if (str->AsArrayIndex(&index)) { | 3506 if (str->AsArrayIndex(&index)) { |
| 3499 i::Handle<i::Object> value; | 3507 i::Handle<i::Object> value; |
| 3500 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { | 3508 if (index <= static_cast<uint32_t>(i::Smi::kMaxValue)) { |
| 3501 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); | 3509 value = i::Handle<i::Object>(i::Smi::FromInt(index), isolate); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3550 | 3558 |
| 3551 bool Value::SameValue(Local<Value> that) const { | 3559 bool Value::SameValue(Local<Value> that) const { |
| 3552 auto self = Utils::OpenHandle(this); | 3560 auto self = Utils::OpenHandle(this); |
| 3553 auto other = Utils::OpenHandle(*that); | 3561 auto other = Utils::OpenHandle(*that); |
| 3554 return self->SameValue(*other); | 3562 return self->SameValue(*other); |
| 3555 } | 3563 } |
| 3556 | 3564 |
| 3557 | 3565 |
| 3558 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, | 3566 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, |
| 3559 v8::Local<Value> key, v8::Local<Value> value) { | 3567 v8::Local<Value> key, v8::Local<Value> value) { |
| 3560 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3568 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_Set, "v8::Object::Set", |
| 3569 bool); | |
| 3561 auto self = Utils::OpenHandle(this); | 3570 auto self = Utils::OpenHandle(this); |
| 3562 auto key_obj = Utils::OpenHandle(*key); | 3571 auto key_obj = Utils::OpenHandle(*key); |
| 3563 auto value_obj = Utils::OpenHandle(*value); | 3572 auto value_obj = Utils::OpenHandle(*value); |
| 3564 has_pending_exception = | 3573 has_pending_exception = |
| 3565 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, | 3574 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, |
| 3566 i::SLOPPY).is_null(); | 3575 i::SLOPPY).is_null(); |
| 3567 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3576 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3568 return Just(true); | 3577 return Just(true); |
| 3569 } | 3578 } |
| 3570 | 3579 |
| 3571 | 3580 |
| 3572 bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) { | 3581 bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) { |
| 3573 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3582 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3574 return Set(context, key, value).FromMaybe(false); | 3583 return Set(context, key, value).FromMaybe(false); |
| 3575 } | 3584 } |
| 3576 | 3585 |
| 3577 | 3586 |
| 3578 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, | 3587 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, |
| 3579 v8::Local<Value> value) { | 3588 v8::Local<Value> value) { |
| 3580 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3589 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_Set, "v8::Object::Set", |
| 3590 bool); | |
| 3581 auto self = Utils::OpenHandle(this); | 3591 auto self = Utils::OpenHandle(this); |
| 3582 auto value_obj = Utils::OpenHandle(*value); | 3592 auto value_obj = Utils::OpenHandle(*value); |
| 3583 has_pending_exception = i::Object::SetElement(isolate, self, index, value_obj, | 3593 has_pending_exception = i::Object::SetElement(isolate, self, index, value_obj, |
| 3584 i::SLOPPY).is_null(); | 3594 i::SLOPPY).is_null(); |
| 3585 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3595 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3586 return Just(true); | 3596 return Just(true); |
| 3587 } | 3597 } |
| 3588 | 3598 |
| 3589 | 3599 |
| 3590 bool v8::Object::Set(uint32_t index, v8::Local<Value> value) { | 3600 bool v8::Object::Set(uint32_t index, v8::Local<Value> value) { |
| 3591 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3601 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3592 return Set(context, index, value).FromMaybe(false); | 3602 return Set(context, index, value).FromMaybe(false); |
| 3593 } | 3603 } |
| 3594 | 3604 |
| 3595 | 3605 |
| 3596 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3606 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
| 3597 v8::Local<Name> key, | 3607 v8::Local<Name> key, |
| 3598 v8::Local<Value> value) { | 3608 v8::Local<Value> value) { |
| 3599 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3609 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_CreateDataProperty, |
| 3600 bool); | 3610 "v8::Object::CreateDataProperty", bool); |
| 3601 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3611 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 3602 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3612 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 3603 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3613 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3604 | 3614 |
| 3605 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 3615 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 3606 isolate, self, key_obj, self, i::LookupIterator::OWN); | 3616 isolate, self, key_obj, self, i::LookupIterator::OWN); |
| 3607 Maybe<bool> result = | 3617 Maybe<bool> result = |
| 3608 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); | 3618 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); |
| 3609 has_pending_exception = result.IsNothing(); | 3619 has_pending_exception = result.IsNothing(); |
| 3610 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3620 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3611 return result; | 3621 return result; |
| 3612 } | 3622 } |
| 3613 | 3623 |
| 3614 | 3624 |
| 3615 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3625 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
| 3616 uint32_t index, | 3626 uint32_t index, |
| 3617 v8::Local<Value> value) { | 3627 v8::Local<Value> value) { |
| 3618 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3628 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_CreateDataProperty, |
| 3619 bool); | 3629 "v8::Object::CreateDataProperty", bool); |
| 3620 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3630 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 3621 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3631 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3622 | 3632 |
| 3623 i::LookupIterator it(isolate, self, index, self, i::LookupIterator::OWN); | 3633 i::LookupIterator it(isolate, self, index, self, i::LookupIterator::OWN); |
| 3624 Maybe<bool> result = | 3634 Maybe<bool> result = |
| 3625 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); | 3635 i::JSReceiver::CreateDataProperty(&it, value_obj, i::Object::DONT_THROW); |
| 3626 has_pending_exception = result.IsNothing(); | 3636 has_pending_exception = result.IsNothing(); |
| 3627 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3637 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3628 return result; | 3638 return result; |
| 3629 } | 3639 } |
| 3630 | 3640 |
| 3631 | 3641 |
| 3632 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, | 3642 Maybe<bool> v8::Object::DefineOwnProperty(v8::Local<v8::Context> context, |
| 3633 v8::Local<Name> key, | 3643 v8::Local<Name> key, |
| 3634 v8::Local<Value> value, | 3644 v8::Local<Value> value, |
| 3635 v8::PropertyAttribute attributes) { | 3645 v8::PropertyAttribute attributes) { |
| 3636 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DefineOwnProperty()", | 3646 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_DefineOwnProperty, |
| 3637 bool); | 3647 "v8::Object::DefineOwnProperty", bool); |
| 3638 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3648 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 3639 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 3649 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 3640 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3650 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3641 | 3651 |
| 3642 if (self->IsAccessCheckNeeded() && | 3652 if (self->IsAccessCheckNeeded() && |
| 3643 !isolate->MayAccess(handle(isolate->context()), | 3653 !isolate->MayAccess(handle(isolate->context()), |
| 3644 i::Handle<i::JSObject>::cast(self))) { | 3654 i::Handle<i::JSObject>::cast(self))) { |
| 3645 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); | 3655 isolate->ReportFailedAccessCheck(i::Handle<i::JSObject>::cast(self)); |
| 3646 return Nothing<bool>(); | 3656 return Nothing<bool>(); |
| 3647 } | 3657 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3670 if (!success) return i::MaybeHandle<i::Object>(); | 3680 if (!success) return i::MaybeHandle<i::Object>(); |
| 3671 | 3681 |
| 3672 return i::JSObject::DefineOwnPropertyIgnoreAttributes( | 3682 return i::JSObject::DefineOwnPropertyIgnoreAttributes( |
| 3673 &it, value, attrs, i::JSObject::FORCE_FIELD); | 3683 &it, value, attrs, i::JSObject::FORCE_FIELD); |
| 3674 } | 3684 } |
| 3675 | 3685 |
| 3676 | 3686 |
| 3677 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, | 3687 Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context, |
| 3678 v8::Local<Value> key, v8::Local<Value> value, | 3688 v8::Local<Value> key, v8::Local<Value> value, |
| 3679 v8::PropertyAttribute attribs) { | 3689 v8::PropertyAttribute attribs) { |
| 3680 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::ForceSet()", bool); | 3690 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_ForceSet, |
| 3691 "v8::Object::ForceSet", bool); | |
| 3681 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3692 auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
| 3682 auto key_obj = Utils::OpenHandle(*key); | 3693 auto key_obj = Utils::OpenHandle(*key); |
| 3683 auto value_obj = Utils::OpenHandle(*value); | 3694 auto value_obj = Utils::OpenHandle(*value); |
| 3684 has_pending_exception = | 3695 has_pending_exception = |
| 3685 DefineObjectProperty(self, key_obj, value_obj, | 3696 DefineObjectProperty(self, key_obj, value_obj, |
| 3686 static_cast<i::PropertyAttributes>(attribs)) | 3697 static_cast<i::PropertyAttributes>(attribs)) |
| 3687 .is_null(); | 3698 .is_null(); |
| 3688 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3699 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3689 return Just(true); | 3700 return Just(true); |
| 3690 } | 3701 } |
| 3691 | 3702 |
| 3692 | 3703 |
| 3693 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, | 3704 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
| 3694 v8::PropertyAttribute attribs) { | 3705 v8::PropertyAttribute attribs) { |
| 3695 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3706 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3696 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), | 3707 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), v8_Object_ForceSet, |
| 3697 "v8::Object::ForceSet", false, i::HandleScope, | 3708 "v8::Object::ForceSet", false, i::HandleScope, |
| 3698 false); | 3709 false); |
| 3699 i::Handle<i::JSObject> self = | 3710 i::Handle<i::JSObject> self = |
| 3700 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); | 3711 i::Handle<i::JSObject>::cast(Utils::OpenHandle(this)); |
| 3701 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3712 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 3702 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3713 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3703 has_pending_exception = | 3714 has_pending_exception = |
| 3704 DefineObjectProperty(self, key_obj, value_obj, | 3715 DefineObjectProperty(self, key_obj, value_obj, |
| 3705 static_cast<i::PropertyAttributes>(attribs)) | 3716 static_cast<i::PropertyAttributes>(attribs)) |
| 3706 .is_null(); | 3717 .is_null(); |
| 3707 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3718 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
| 3708 return true; | 3719 return true; |
| 3709 } | 3720 } |
| 3710 | 3721 |
| 3711 | 3722 |
| 3712 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, | 3723 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, |
| 3713 Local<Value> value) { | 3724 Local<Value> value) { |
| 3714 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrivate()", bool); | 3725 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_SetPrivate, |
| 3726 "v8::Object::SetPrivate", bool); | |
| 3715 auto self = Utils::OpenHandle(this); | 3727 auto self = Utils::OpenHandle(this); |
| 3716 auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); | 3728 auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); |
| 3717 auto value_obj = Utils::OpenHandle(*value); | 3729 auto value_obj = Utils::OpenHandle(*value); |
| 3718 if (self->IsJSProxy()) { | 3730 if (self->IsJSProxy()) { |
| 3719 i::PropertyDescriptor desc; | 3731 i::PropertyDescriptor desc; |
| 3720 desc.set_writable(true); | 3732 desc.set_writable(true); |
| 3721 desc.set_enumerable(false); | 3733 desc.set_enumerable(false); |
| 3722 desc.set_configurable(true); | 3734 desc.set_configurable(true); |
| 3723 desc.set_value(value_obj); | 3735 desc.set_value(value_obj); |
| 3724 return i::JSProxy::SetPrivateProperty( | 3736 return i::JSProxy::SetPrivateProperty( |
| 3725 isolate, i::Handle<i::JSProxy>::cast(self), | 3737 isolate, i::Handle<i::JSProxy>::cast(self), |
| 3726 i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW); | 3738 i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW); |
| 3727 } | 3739 } |
| 3728 auto js_object = i::Handle<i::JSObject>::cast(self); | 3740 auto js_object = i::Handle<i::JSObject>::cast(self); |
| 3729 i::LookupIterator it(js_object, key_obj, js_object); | 3741 i::LookupIterator it(js_object, key_obj, js_object); |
| 3730 has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( | 3742 has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( |
| 3731 &it, value_obj, i::DONT_ENUM) | 3743 &it, value_obj, i::DONT_ENUM) |
| 3732 .is_null(); | 3744 .is_null(); |
| 3733 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3745 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3734 return Just(true); | 3746 return Just(true); |
| 3735 } | 3747 } |
| 3736 | 3748 |
| 3737 | 3749 |
| 3738 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3750 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
| 3739 Local<Value> key) { | 3751 Local<Value> key) { |
| 3740 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3752 PREPARE_FOR_EXECUTION(context, v8_Object_Get, "v8::Object::Get", Value); |
| 3741 auto self = Utils::OpenHandle(this); | 3753 auto self = Utils::OpenHandle(this); |
| 3742 auto key_obj = Utils::OpenHandle(*key); | 3754 auto key_obj = Utils::OpenHandle(*key); |
| 3743 i::Handle<i::Object> result; | 3755 i::Handle<i::Object> result; |
| 3744 has_pending_exception = | 3756 has_pending_exception = |
| 3745 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); | 3757 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); |
| 3746 RETURN_ON_FAILED_EXECUTION(Value); | 3758 RETURN_ON_FAILED_EXECUTION(Value); |
| 3747 RETURN_ESCAPED(Utils::ToLocal(result)); | 3759 RETURN_ESCAPED(Utils::ToLocal(result)); |
| 3748 } | 3760 } |
| 3749 | 3761 |
| 3750 | 3762 |
| 3751 Local<Value> v8::Object::Get(v8::Local<Value> key) { | 3763 Local<Value> v8::Object::Get(v8::Local<Value> key) { |
| 3752 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3764 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3753 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); | 3765 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); |
| 3754 } | 3766 } |
| 3755 | 3767 |
| 3756 | 3768 |
| 3757 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { | 3769 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { |
| 3758 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3770 PREPARE_FOR_EXECUTION(context, v8_Object_Get, "v8::Object::Get", Value); |
| 3759 auto self = Utils::OpenHandle(this); | 3771 auto self = Utils::OpenHandle(this); |
| 3760 i::Handle<i::Object> result; | 3772 i::Handle<i::Object> result; |
| 3761 has_pending_exception = | 3773 has_pending_exception = |
| 3762 !i::JSReceiver::GetElement(isolate, self, index).ToHandle(&result); | 3774 !i::JSReceiver::GetElement(isolate, self, index).ToHandle(&result); |
| 3763 RETURN_ON_FAILED_EXECUTION(Value); | 3775 RETURN_ON_FAILED_EXECUTION(Value); |
| 3764 RETURN_ESCAPED(Utils::ToLocal(result)); | 3776 RETURN_ESCAPED(Utils::ToLocal(result)); |
| 3765 } | 3777 } |
| 3766 | 3778 |
| 3767 | 3779 |
| 3768 Local<Value> v8::Object::Get(uint32_t index) { | 3780 Local<Value> v8::Object::Get(uint32_t index) { |
| 3769 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3781 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3770 RETURN_TO_LOCAL_UNCHECKED(Get(context, index), Value); | 3782 RETURN_TO_LOCAL_UNCHECKED(Get(context, index), Value); |
| 3771 } | 3783 } |
| 3772 | 3784 |
| 3773 | 3785 |
| 3774 MaybeLocal<Value> v8::Object::GetPrivate(Local<Context> context, | 3786 MaybeLocal<Value> v8::Object::GetPrivate(Local<Context> context, |
| 3775 Local<Private> key) { | 3787 Local<Private> key) { |
| 3776 return Get(context, Local<Value>(reinterpret_cast<Value*>(*key))); | 3788 return Get(context, Local<Value>(reinterpret_cast<Value*>(*key))); |
| 3777 } | 3789 } |
| 3778 | 3790 |
| 3779 | 3791 |
| 3780 Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes( | 3792 Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes( |
| 3781 Local<Context> context, Local<Value> key) { | 3793 Local<Context> context, Local<Value> key) { |
| 3782 PREPARE_FOR_EXECUTION_PRIMITIVE( | 3794 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_GetPropertyAttributes, |
| 3783 context, "v8::Object::GetPropertyAttributes()", PropertyAttribute); | 3795 "v8::Object::GetPropertyAttributes", |
| 3796 PropertyAttribute); | |
| 3784 auto self = Utils::OpenHandle(this); | 3797 auto self = Utils::OpenHandle(this); |
| 3785 auto key_obj = Utils::OpenHandle(*key); | 3798 auto key_obj = Utils::OpenHandle(*key); |
| 3786 if (!key_obj->IsName()) { | 3799 if (!key_obj->IsName()) { |
| 3787 has_pending_exception = | 3800 has_pending_exception = |
| 3788 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); | 3801 !i::Object::ToString(isolate, key_obj).ToHandle(&key_obj); |
| 3789 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3802 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 3790 } | 3803 } |
| 3791 auto key_name = i::Handle<i::Name>::cast(key_obj); | 3804 auto key_name = i::Handle<i::Name>::cast(key_obj); |
| 3792 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); | 3805 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); |
| 3793 has_pending_exception = result.IsNothing(); | 3806 has_pending_exception = result.IsNothing(); |
| 3794 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3807 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 3795 if (result.FromJust() == i::ABSENT) { | 3808 if (result.FromJust() == i::ABSENT) { |
| 3796 return Just(static_cast<PropertyAttribute>(i::NONE)); | 3809 return Just(static_cast<PropertyAttribute>(i::NONE)); |
| 3797 } | 3810 } |
| 3798 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 3811 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
| 3799 } | 3812 } |
| 3800 | 3813 |
| 3801 | 3814 |
| 3802 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { | 3815 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { |
| 3803 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3816 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3804 return GetPropertyAttributes(context, key) | 3817 return GetPropertyAttributes(context, key) |
| 3805 .FromMaybe(static_cast<PropertyAttribute>(i::NONE)); | 3818 .FromMaybe(static_cast<PropertyAttribute>(i::NONE)); |
| 3806 } | 3819 } |
| 3807 | 3820 |
| 3808 | 3821 |
| 3809 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, | 3822 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, |
| 3810 Local<String> key) { | 3823 Local<String> key) { |
| 3811 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", | 3824 PREPARE_FOR_EXECUTION(context, v8_Object_GetOwnPropertyDescriptor, |
| 3812 Value); | 3825 "v8::Object::GetOwnPropertyDescriptor", Value); |
| 3813 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); | 3826 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
| 3814 i::Handle<i::String> key_name = Utils::OpenHandle(*key); | 3827 i::Handle<i::String> key_name = Utils::OpenHandle(*key); |
| 3815 | 3828 |
| 3816 i::PropertyDescriptor desc; | 3829 i::PropertyDescriptor desc; |
| 3817 Maybe<bool> found = | 3830 Maybe<bool> found = |
| 3818 i::JSReceiver::GetOwnPropertyDescriptor(isolate, obj, key_name, &desc); | 3831 i::JSReceiver::GetOwnPropertyDescriptor(isolate, obj, key_name, &desc); |
| 3819 has_pending_exception = found.IsNothing(); | 3832 has_pending_exception = found.IsNothing(); |
| 3820 RETURN_ON_FAILED_EXECUTION(Value); | 3833 RETURN_ON_FAILED_EXECUTION(Value); |
| 3821 if (!found.FromJust()) { | 3834 if (!found.FromJust()) { |
| 3822 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 3835 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 3834 Local<Value> v8::Object::GetPrototype() { | 3847 Local<Value> v8::Object::GetPrototype() { |
| 3835 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 3848 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3836 auto self = Utils::OpenHandle(this); | 3849 auto self = Utils::OpenHandle(this); |
| 3837 i::PrototypeIterator iter(isolate, self); | 3850 i::PrototypeIterator iter(isolate, self); |
| 3838 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); | 3851 return Utils::ToLocal(i::PrototypeIterator::GetCurrent(iter)); |
| 3839 } | 3852 } |
| 3840 | 3853 |
| 3841 | 3854 |
| 3842 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, | 3855 Maybe<bool> v8::Object::SetPrototype(Local<Context> context, |
| 3843 Local<Value> value) { | 3856 Local<Value> value) { |
| 3844 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrototype()", bool); | 3857 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_SetPrototype, |
| 3858 "v8::Object::SetPrototype", bool); | |
| 3845 auto self = Utils::OpenHandle(this); | 3859 auto self = Utils::OpenHandle(this); |
| 3846 auto value_obj = Utils::OpenHandle(*value); | 3860 auto value_obj = Utils::OpenHandle(*value); |
| 3847 // We do not allow exceptions thrown while setting the prototype | 3861 // We do not allow exceptions thrown while setting the prototype |
| 3848 // to propagate outside. | 3862 // to propagate outside. |
| 3849 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 3863 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
| 3850 auto result = i::JSReceiver::SetPrototype(self, value_obj, false, | 3864 auto result = i::JSReceiver::SetPrototype(self, value_obj, false, |
| 3851 i::Object::THROW_ON_ERROR); | 3865 i::Object::THROW_ON_ERROR); |
| 3852 has_pending_exception = result.IsNothing(); | 3866 has_pending_exception = result.IsNothing(); |
| 3853 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3867 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3854 return Just(true); | 3868 return Just(true); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 3872 if (iter.IsAtEnd()) { | 3886 if (iter.IsAtEnd()) { |
| 3873 return Local<Object>(); | 3887 return Local<Object>(); |
| 3874 } | 3888 } |
| 3875 } | 3889 } |
| 3876 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. | 3890 // IsTemplateFor() ensures that iter.GetCurrent() can't be a Proxy here. |
| 3877 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); | 3891 return Utils::ToLocal(i::handle(iter.GetCurrent<i::JSObject>(), isolate)); |
| 3878 } | 3892 } |
| 3879 | 3893 |
| 3880 | 3894 |
| 3881 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { | 3895 MaybeLocal<Array> v8::Object::GetPropertyNames(Local<Context> context) { |
| 3882 PREPARE_FOR_EXECUTION(context, "v8::Object::GetPropertyNames()", Array); | 3896 PREPARE_FOR_EXECUTION(context, v8_Object_GetPropertyNames, |
| 3897 "v8::Object::GetPropertyNames", Array); | |
| 3883 auto self = Utils::OpenHandle(this); | 3898 auto self = Utils::OpenHandle(this); |
| 3884 i::Handle<i::FixedArray> value; | 3899 i::Handle<i::FixedArray> value; |
| 3885 has_pending_exception = | 3900 has_pending_exception = |
| 3886 !i::JSReceiver::GetKeys(self, i::INCLUDE_PROTOS, i::ENUMERABLE_STRINGS) | 3901 !i::JSReceiver::GetKeys(self, i::INCLUDE_PROTOS, i::ENUMERABLE_STRINGS) |
| 3887 .ToHandle(&value); | 3902 .ToHandle(&value); |
| 3888 RETURN_ON_FAILED_EXECUTION(Array); | 3903 RETURN_ON_FAILED_EXECUTION(Array); |
| 3889 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | 3904 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
| 3890 self->map()->EnumLength() == 0 || | 3905 self->map()->EnumLength() == 0 || |
| 3891 self->map()->instance_descriptors()->GetEnumCache() != *value); | 3906 self->map()->instance_descriptors()->GetEnumCache() != *value); |
| 3892 auto result = isolate->factory()->NewJSArrayWithElements(value); | 3907 auto result = isolate->factory()->NewJSArrayWithElements(value); |
| 3893 RETURN_ESCAPED(Utils::ToLocal(result)); | 3908 RETURN_ESCAPED(Utils::ToLocal(result)); |
| 3894 } | 3909 } |
| 3895 | 3910 |
| 3896 | 3911 |
| 3897 Local<Array> v8::Object::GetPropertyNames() { | 3912 Local<Array> v8::Object::GetPropertyNames() { |
| 3898 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3913 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3899 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); | 3914 RETURN_TO_LOCAL_UNCHECKED(GetPropertyNames(context), Array); |
| 3900 } | 3915 } |
| 3901 | 3916 |
| 3902 | 3917 |
| 3903 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { | 3918 MaybeLocal<Array> v8::Object::GetOwnPropertyNames(Local<Context> context) { |
| 3904 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyNames()", Array); | 3919 PREPARE_FOR_EXECUTION(context, v8_Object_GetOwnPropertyNames, |
| 3920 "v8::Object::GetOwnPropertyNames", Array); | |
| 3905 auto self = Utils::OpenHandle(this); | 3921 auto self = Utils::OpenHandle(this); |
| 3906 i::Handle<i::FixedArray> value; | 3922 i::Handle<i::FixedArray> value; |
| 3907 has_pending_exception = | 3923 has_pending_exception = |
| 3908 !i::JSReceiver::GetKeys(self, i::OWN_ONLY, i::ENUMERABLE_STRINGS) | 3924 !i::JSReceiver::GetKeys(self, i::OWN_ONLY, i::ENUMERABLE_STRINGS) |
| 3909 .ToHandle(&value); | 3925 .ToHandle(&value); |
| 3910 RETURN_ON_FAILED_EXECUTION(Array); | 3926 RETURN_ON_FAILED_EXECUTION(Array); |
| 3911 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || | 3927 DCHECK(self->map()->EnumLength() == i::kInvalidEnumCacheSentinel || |
| 3912 self->map()->EnumLength() == 0 || | 3928 self->map()->EnumLength() == 0 || |
| 3913 self->map()->instance_descriptors()->GetEnumCache() != *value); | 3929 self->map()->instance_descriptors()->GetEnumCache() != *value); |
| 3914 auto result = isolate->factory()->NewJSArrayWithElements(value); | 3930 auto result = isolate->factory()->NewJSArrayWithElements(value); |
| 3915 RETURN_ESCAPED(Utils::ToLocal(result)); | 3931 RETURN_ESCAPED(Utils::ToLocal(result)); |
| 3916 } | 3932 } |
| 3917 | 3933 |
| 3918 | 3934 |
| 3919 Local<Array> v8::Object::GetOwnPropertyNames() { | 3935 Local<Array> v8::Object::GetOwnPropertyNames() { |
| 3920 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3936 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3921 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); | 3937 RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyNames(context), Array); |
| 3922 } | 3938 } |
| 3923 | 3939 |
| 3924 | 3940 |
| 3925 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { | 3941 MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) { |
| 3926 PREPARE_FOR_EXECUTION(context, "v8::Object::ObjectProtoToString", String); | 3942 PREPARE_FOR_EXECUTION(context, v8_Object_ObjectProtoToString, |
| 3943 "v8::Object::ObjectProtoToString", String); | |
| 3927 auto obj = Utils::OpenHandle(this); | 3944 auto obj = Utils::OpenHandle(this); |
| 3928 Local<String> result; | 3945 Local<String> result; |
| 3929 has_pending_exception = | 3946 has_pending_exception = |
| 3930 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); | 3947 !ToLocal<String>(i::JSObject::ObjectProtoToString(isolate, obj), &result); |
| 3931 RETURN_ON_FAILED_EXECUTION(String); | 3948 RETURN_ON_FAILED_EXECUTION(String); |
| 3932 RETURN_ESCAPED(result); | 3949 RETURN_ESCAPED(result); |
| 3933 } | 3950 } |
| 3934 | 3951 |
| 3935 | 3952 |
| 3936 Local<String> v8::Object::ObjectProtoToString() { | 3953 Local<String> v8::Object::ObjectProtoToString() { |
| 3937 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3954 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3938 RETURN_TO_LOCAL_UNCHECKED(ObjectProtoToString(context), String); | 3955 RETURN_TO_LOCAL_UNCHECKED(ObjectProtoToString(context), String); |
| 3939 } | 3956 } |
| 3940 | 3957 |
| 3941 | 3958 |
| 3942 Local<String> v8::Object::GetConstructorName() { | 3959 Local<String> v8::Object::GetConstructorName() { |
| 3943 auto self = Utils::OpenHandle(this); | 3960 auto self = Utils::OpenHandle(this); |
| 3944 i::Handle<i::String> name = i::JSReceiver::GetConstructorName(self); | 3961 i::Handle<i::String> name = i::JSReceiver::GetConstructorName(self); |
| 3945 return Utils::ToLocal(name); | 3962 return Utils::ToLocal(name); |
| 3946 } | 3963 } |
| 3947 | 3964 |
| 3948 Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context, | 3965 Maybe<bool> v8::Object::SetIntegrityLevel(Local<Context> context, |
| 3949 IntegrityLevel level) { | 3966 IntegrityLevel level) { |
| 3950 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetIntegrityLevel()", | 3967 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_SetIntegrityLevel, |
| 3951 bool); | 3968 "v8::Object::SetIntegrityLevel", bool); |
| 3952 auto self = Utils::OpenHandle(this); | 3969 auto self = Utils::OpenHandle(this); |
| 3953 i::JSReceiver::IntegrityLevel i_level = | 3970 i::JSReceiver::IntegrityLevel i_level = |
| 3954 level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED; | 3971 level == IntegrityLevel::kFrozen ? i::FROZEN : i::SEALED; |
| 3955 Maybe<bool> result = | 3972 Maybe<bool> result = |
| 3956 i::JSReceiver::SetIntegrityLevel(self, i_level, i::Object::DONT_THROW); | 3973 i::JSReceiver::SetIntegrityLevel(self, i_level, i::Object::DONT_THROW); |
| 3957 has_pending_exception = result.IsNothing(); | 3974 has_pending_exception = result.IsNothing(); |
| 3958 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3975 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3959 return result; | 3976 return result; |
| 3960 } | 3977 } |
| 3961 | 3978 |
| 3962 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { | 3979 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { |
| 3963 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool); | 3980 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_Delete, |
| 3981 "v8::Object::Delete", bool); | |
| 3964 auto self = Utils::OpenHandle(this); | 3982 auto self = Utils::OpenHandle(this); |
| 3965 auto key_obj = Utils::OpenHandle(*key); | 3983 auto key_obj = Utils::OpenHandle(*key); |
| 3966 Maybe<bool> result = | 3984 Maybe<bool> result = |
| 3967 i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY); | 3985 i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY); |
| 3968 has_pending_exception = result.IsNothing(); | 3986 has_pending_exception = result.IsNothing(); |
| 3969 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3987 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3970 return result; | 3988 return result; |
| 3971 } | 3989 } |
| 3972 | 3990 |
| 3973 | 3991 |
| 3974 bool v8::Object::Delete(v8::Local<Value> key) { | 3992 bool v8::Object::Delete(v8::Local<Value> key) { |
| 3975 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3993 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3976 return Delete(context, key).FromMaybe(false); | 3994 return Delete(context, key).FromMaybe(false); |
| 3977 } | 3995 } |
| 3978 | 3996 |
| 3979 | 3997 |
| 3980 Maybe<bool> v8::Object::DeletePrivate(Local<Context> context, | 3998 Maybe<bool> v8::Object::DeletePrivate(Local<Context> context, |
| 3981 Local<Private> key) { | 3999 Local<Private> key) { |
| 3982 return Delete(context, Local<Value>(reinterpret_cast<Value*>(*key))); | 4000 return Delete(context, Local<Value>(reinterpret_cast<Value*>(*key))); |
| 3983 } | 4001 } |
| 3984 | 4002 |
| 3985 | 4003 |
| 3986 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { | 4004 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { |
| 3987 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 4005 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_Get, "v8::Object::Get", |
| 4006 bool); | |
| 3988 auto self = Utils::OpenHandle(this); | 4007 auto self = Utils::OpenHandle(this); |
| 3989 auto key_obj = Utils::OpenHandle(*key); | 4008 auto key_obj = Utils::OpenHandle(*key); |
| 3990 Maybe<bool> maybe = Nothing<bool>(); | 4009 Maybe<bool> maybe = Nothing<bool>(); |
| 3991 // Check if the given key is an array index. | 4010 // Check if the given key is an array index. |
| 3992 uint32_t index = 0; | 4011 uint32_t index = 0; |
| 3993 if (key_obj->ToArrayIndex(&index)) { | 4012 if (key_obj->ToArrayIndex(&index)) { |
| 3994 maybe = i::JSReceiver::HasElement(self, index); | 4013 maybe = i::JSReceiver::HasElement(self, index); |
| 3995 } else { | 4014 } else { |
| 3996 // Convert the key to a name - possibly by calling back into JavaScript. | 4015 // Convert the key to a name - possibly by calling back into JavaScript. |
| 3997 i::Handle<i::Name> name; | 4016 i::Handle<i::Name> name; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 4010 return Has(context, key).FromMaybe(false); | 4029 return Has(context, key).FromMaybe(false); |
| 4011 } | 4030 } |
| 4012 | 4031 |
| 4013 | 4032 |
| 4014 Maybe<bool> v8::Object::HasPrivate(Local<Context> context, Local<Private> key) { | 4033 Maybe<bool> v8::Object::HasPrivate(Local<Context> context, Local<Private> key) { |
| 4015 return HasOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key))); | 4034 return HasOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key))); |
| 4016 } | 4035 } |
| 4017 | 4036 |
| 4018 | 4037 |
| 4019 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { | 4038 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { |
| 4020 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DeleteProperty()", | 4039 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_DeleteProperty, |
| 4021 bool); | 4040 "v8::Object::DeleteProperty", bool); |
| 4022 auto self = Utils::OpenHandle(this); | 4041 auto self = Utils::OpenHandle(this); |
| 4023 Maybe<bool> result = i::JSReceiver::DeleteElement(self, index); | 4042 Maybe<bool> result = i::JSReceiver::DeleteElement(self, index); |
| 4024 has_pending_exception = result.IsNothing(); | 4043 has_pending_exception = result.IsNothing(); |
| 4025 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4044 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4026 return result; | 4045 return result; |
| 4027 } | 4046 } |
| 4028 | 4047 |
| 4029 | 4048 |
| 4030 bool v8::Object::Delete(uint32_t index) { | 4049 bool v8::Object::Delete(uint32_t index) { |
| 4031 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4050 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4032 return Delete(context, index).FromMaybe(false); | 4051 return Delete(context, index).FromMaybe(false); |
| 4033 } | 4052 } |
| 4034 | 4053 |
| 4035 | 4054 |
| 4036 Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) { | 4055 Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) { |
| 4037 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 4056 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_Get, "v8::Object::Get", |
| 4057 bool); | |
| 4038 auto self = Utils::OpenHandle(this); | 4058 auto self = Utils::OpenHandle(this); |
| 4039 auto maybe = i::JSReceiver::HasElement(self, index); | 4059 auto maybe = i::JSReceiver::HasElement(self, index); |
| 4040 has_pending_exception = maybe.IsNothing(); | 4060 has_pending_exception = maybe.IsNothing(); |
| 4041 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4061 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4042 return maybe; | 4062 return maybe; |
| 4043 } | 4063 } |
| 4044 | 4064 |
| 4045 | 4065 |
| 4046 bool v8::Object::Has(uint32_t index) { | 4066 bool v8::Object::Has(uint32_t index) { |
| 4047 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4067 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4048 return Has(context, index).FromMaybe(false); | 4068 return Has(context, index).FromMaybe(false); |
| 4049 } | 4069 } |
| 4050 | 4070 |
| 4051 | 4071 |
| 4052 template <typename Getter, typename Setter, typename Data> | 4072 template <typename Getter, typename Setter, typename Data> |
| 4053 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, | 4073 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self, |
| 4054 Local<Name> name, Getter getter, | 4074 Local<Name> name, Getter getter, |
| 4055 Setter setter, Data data, | 4075 Setter setter, Data data, |
| 4056 AccessControl settings, | 4076 AccessControl settings, |
| 4057 PropertyAttribute attributes) { | 4077 PropertyAttribute attributes) { |
| 4058 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); | 4078 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_SetAccessor, |
| 4079 "v8::Object::SetAccessor", bool); | |
| 4059 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); | 4080 if (!Utils::OpenHandle(self)->IsJSObject()) return Just(false); |
| 4060 i::Handle<i::JSObject> obj = | 4081 i::Handle<i::JSObject> obj = |
| 4061 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); | 4082 i::Handle<i::JSObject>::cast(Utils::OpenHandle(self)); |
| 4062 v8::Local<AccessorSignature> signature; | 4083 v8::Local<AccessorSignature> signature; |
| 4063 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, | 4084 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, |
| 4064 signature, i::FLAG_disable_old_api_accessors); | 4085 signature, i::FLAG_disable_old_api_accessors); |
| 4065 if (info.is_null()) return Nothing<bool>(); | 4086 if (info.is_null()) return Nothing<bool>(); |
| 4066 bool fast = obj->HasFastProperties(); | 4087 bool fast = obj->HasFastProperties(); |
| 4067 i::Handle<i::Object> result; | 4088 i::Handle<i::Object> result; |
| 4068 has_pending_exception = | 4089 has_pending_exception = |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4120 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 4141 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
| 4121 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 4142 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
| 4122 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), | 4143 i::JSObject::DefineAccessor(i::Handle<i::JSObject>::cast(self), |
| 4123 v8::Utils::OpenHandle(*name), getter_i, setter_i, | 4144 v8::Utils::OpenHandle(*name), getter_i, setter_i, |
| 4124 static_cast<i::PropertyAttributes>(attribute)); | 4145 static_cast<i::PropertyAttributes>(attribute)); |
| 4125 } | 4146 } |
| 4126 | 4147 |
| 4127 | 4148 |
| 4128 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, | 4149 Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, |
| 4129 Local<Name> key) { | 4150 Local<Name> key) { |
| 4130 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasOwnProperty()", | 4151 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_HasOwnProperty, |
| 4131 bool); | 4152 "v8::Object::HasOwnProperty", bool); |
| 4132 auto self = Utils::OpenHandle(this); | 4153 auto self = Utils::OpenHandle(this); |
| 4133 auto key_val = Utils::OpenHandle(*key); | 4154 auto key_val = Utils::OpenHandle(*key); |
| 4134 auto result = i::JSReceiver::HasOwnProperty(self, key_val); | 4155 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
| 4135 has_pending_exception = result.IsNothing(); | 4156 has_pending_exception = result.IsNothing(); |
| 4136 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4157 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4137 return result; | 4158 return result; |
| 4138 } | 4159 } |
| 4139 | 4160 |
| 4140 | 4161 |
| 4141 bool v8::Object::HasOwnProperty(Local<String> key) { | 4162 bool v8::Object::HasOwnProperty(Local<String> key) { |
| 4142 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4163 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4143 return HasOwnProperty(context, key).FromMaybe(false); | 4164 return HasOwnProperty(context, key).FromMaybe(false); |
| 4144 } | 4165 } |
| 4145 | 4166 |
| 4146 | 4167 |
| 4147 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, | 4168 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
| 4148 Local<Name> key) { | 4169 Local<Name> key) { |
| 4149 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", | 4170 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_HasRealNamedProperty, |
| 4150 bool); | 4171 "v8::Object::HasRealNamedProperty", bool); |
| 4151 auto self = Utils::OpenHandle(this); | 4172 auto self = Utils::OpenHandle(this); |
| 4152 if (!self->IsJSObject()) return Just(false); | 4173 if (!self->IsJSObject()) return Just(false); |
| 4153 auto key_val = Utils::OpenHandle(*key); | 4174 auto key_val = Utils::OpenHandle(*key); |
| 4154 auto result = i::JSObject::HasRealNamedProperty( | 4175 auto result = i::JSObject::HasRealNamedProperty( |
| 4155 i::Handle<i::JSObject>::cast(self), key_val); | 4176 i::Handle<i::JSObject>::cast(self), key_val); |
| 4156 has_pending_exception = result.IsNothing(); | 4177 has_pending_exception = result.IsNothing(); |
| 4157 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4178 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4158 return result; | 4179 return result; |
| 4159 } | 4180 } |
| 4160 | 4181 |
| 4161 | 4182 |
| 4162 bool v8::Object::HasRealNamedProperty(Local<String> key) { | 4183 bool v8::Object::HasRealNamedProperty(Local<String> key) { |
| 4163 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4184 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4164 return HasRealNamedProperty(context, key).FromMaybe(false); | 4185 return HasRealNamedProperty(context, key).FromMaybe(false); |
| 4165 } | 4186 } |
| 4166 | 4187 |
| 4167 | 4188 |
| 4168 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, | 4189 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
| 4169 uint32_t index) { | 4190 uint32_t index) { |
| 4170 PREPARE_FOR_EXECUTION_PRIMITIVE(context, | 4191 PREPARE_FOR_EXECUTION_PRIMITIVE(context, v8_Object_HasRealIndexedProperty, |
| 4171 "v8::Object::HasRealIndexedProperty()", bool); | 4192 "v8::Object::HasRealIndexedProperty", bool); |
| 4172 auto self = Utils::OpenHandle(this); | 4193 auto self = Utils::OpenHandle(this); |
| 4173 if (!self->IsJSObject()) return Just(false); | 4194 if (!self->IsJSObject()) return Just(false); |
| 4174 auto result = i::JSObject::HasRealElementProperty( | 4195 auto result = i::JSObject::HasRealElementProperty( |
| 4175 i::Handle<i::JSObject>::cast(self), index); | 4196 i::Handle<i::JSObject>::cast(self), index); |
| 4176 has_pending_exception = result.IsNothing(); | 4197 has_pending_exception = result.IsNothing(); |
| 4177 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4198 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4178 return result; | 4199 return result; |
| 4179 } | 4200 } |
| 4180 | 4201 |
| 4181 | 4202 |
| 4182 bool v8::Object::HasRealIndexedProperty(uint32_t index) { | 4203 bool v8::Object::HasRealIndexedProperty(uint32_t index) { |
| 4183 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4204 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4184 return HasRealIndexedProperty(context, index).FromMaybe(false); | 4205 return HasRealIndexedProperty(context, index).FromMaybe(false); |
| 4185 } | 4206 } |
| 4186 | 4207 |
| 4187 | 4208 |
| 4188 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, | 4209 Maybe<bool> v8::Object::HasRealNamedCallbackProperty(Local<Context> context, |
| 4189 Local<Name> key) { | 4210 Local<Name> key) { |
| 4190 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4211 PREPARE_FOR_EXECUTION_PRIMITIVE( |
| 4191 context, "v8::Object::HasRealNamedCallbackProperty()", bool); | 4212 context, v8_Object_HasRealNamedCallbackProperty, |
| 4213 "v8::Object::HasRealNamedCallbackProperty", bool); | |
| 4192 auto self = Utils::OpenHandle(this); | 4214 auto self = Utils::OpenHandle(this); |
| 4193 if (!self->IsJSObject()) return Just(false); | 4215 if (!self->IsJSObject()) return Just(false); |
| 4194 auto key_val = Utils::OpenHandle(*key); | 4216 auto key_val = Utils::OpenHandle(*key); |
| 4195 auto result = i::JSObject::HasRealNamedCallbackProperty( | 4217 auto result = i::JSObject::HasRealNamedCallbackProperty( |
| 4196 i::Handle<i::JSObject>::cast(self), key_val); | 4218 i::Handle<i::JSObject>::cast(self), key_val); |
| 4197 has_pending_exception = result.IsNothing(); | 4219 has_pending_exception = result.IsNothing(); |
| 4198 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4220 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 4199 return result; | 4221 return result; |
| 4200 } | 4222 } |
| 4201 | 4223 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 4215 | 4237 |
| 4216 bool v8::Object::HasIndexedLookupInterceptor() { | 4238 bool v8::Object::HasIndexedLookupInterceptor() { |
| 4217 auto self = Utils::OpenHandle(this); | 4239 auto self = Utils::OpenHandle(this); |
| 4218 return self->IsJSObject() && | 4240 return self->IsJSObject() && |
| 4219 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); | 4241 i::Handle<i::JSObject>::cast(self)->HasIndexedInterceptor(); |
| 4220 } | 4242 } |
| 4221 | 4243 |
| 4222 | 4244 |
| 4223 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4245 MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
| 4224 Local<Context> context, Local<Name> key) { | 4246 Local<Context> context, Local<Name> key) { |
| 4225 PREPARE_FOR_EXECUTION( | 4247 PREPARE_FOR_EXECUTION(context, v8_Object_GetRealNamedPropertyInPrototypeChain, |
| 4226 context, "v8::Object::GetRealNamedPropertyInPrototypeChain()", Value); | 4248 "v8::Object::GetRealNamedPropertyInPrototypeChain", |
| 4249 Value); | |
| 4227 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 4250 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4228 if (!self->IsJSObject()) return MaybeLocal<Value>(); | 4251 if (!self->IsJSObject()) return MaybeLocal<Value>(); |
| 4229 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4252 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 4230 i::PrototypeIterator iter(isolate, self); | 4253 i::PrototypeIterator iter(isolate, self); |
| 4231 if (iter.IsAtEnd()) return MaybeLocal<Value>(); | 4254 if (iter.IsAtEnd()) return MaybeLocal<Value>(); |
| 4232 i::Handle<i::JSReceiver> proto = | 4255 i::Handle<i::JSReceiver> proto = |
| 4233 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4256 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
| 4234 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4257 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4235 isolate, self, key_obj, proto, | 4258 isolate, self, key_obj, proto, |
| 4236 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4259 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 4247 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4270 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4248 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), | 4271 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), |
| 4249 Value); | 4272 Value); |
| 4250 } | 4273 } |
| 4251 | 4274 |
| 4252 | 4275 |
| 4253 Maybe<PropertyAttribute> | 4276 Maybe<PropertyAttribute> |
| 4254 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( | 4277 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
| 4255 Local<Context> context, Local<Name> key) { | 4278 Local<Context> context, Local<Name> key) { |
| 4256 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4279 PREPARE_FOR_EXECUTION_PRIMITIVE( |
| 4257 context, "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain()", | 4280 context, v8_Object_GetRealNamedPropertyAttributesInPrototypeChain, |
| 4281 "v8::Object::GetRealNamedPropertyAttributesInPrototypeChain", | |
| 4258 PropertyAttribute); | 4282 PropertyAttribute); |
| 4259 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 4283 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
| 4260 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); | 4284 if (!self->IsJSObject()) return Nothing<PropertyAttribute>(); |
| 4261 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); | 4285 i::Handle<i::Name> key_obj = Utils::OpenHandle(*key); |
| 4262 i::PrototypeIterator iter(isolate, self); | 4286 i::PrototypeIterator iter(isolate, self); |
| 4263 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); | 4287 if (iter.IsAtEnd()) return Nothing<PropertyAttribute>(); |
| 4264 i::Handle<i::JSReceiver> proto = | 4288 i::Handle<i::JSReceiver> proto = |
| 4265 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); | 4289 i::PrototypeIterator::GetCurrent<i::JSReceiver>(iter); |
| 4266 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4290 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4267 isolate, self, key_obj, proto, | 4291 isolate, self, key_obj, proto, |
| 4268 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4292 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 4269 Maybe<i::PropertyAttributes> result = | 4293 Maybe<i::PropertyAttributes> result = |
| 4270 i::JSReceiver::GetPropertyAttributes(&it); | 4294 i::JSReceiver::GetPropertyAttributes(&it); |
| 4271 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4295 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 4272 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4296 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
| 4273 if (result.FromJust() == i::ABSENT) return Just(None); | 4297 if (result.FromJust() == i::ABSENT) return Just(None); |
| 4274 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 4298 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
| 4275 } | 4299 } |
| 4276 | 4300 |
| 4277 | 4301 |
| 4278 Maybe<PropertyAttribute> | 4302 Maybe<PropertyAttribute> |
| 4279 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { | 4303 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { |
| 4280 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4304 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4281 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); | 4305 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
| 4282 } | 4306 } |
| 4283 | 4307 |
| 4284 | 4308 |
| 4285 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, | 4309 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, |
| 4286 Local<Name> key) { | 4310 Local<Name> key) { |
| 4287 PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value); | 4311 PREPARE_FOR_EXECUTION(context, v8_Object_GetRealNamedProperty, |
| 4312 "v8::Object::GetRealNamedProperty", Value); | |
| 4288 auto self = Utils::OpenHandle(this); | 4313 auto self = Utils::OpenHandle(this); |
| 4289 auto key_obj = Utils::OpenHandle(*key); | 4314 auto key_obj = Utils::OpenHandle(*key); |
| 4290 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4315 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4291 isolate, self, key_obj, self, | 4316 isolate, self, key_obj, self, |
| 4292 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4317 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 4293 Local<Value> result; | 4318 Local<Value> result; |
| 4294 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4319 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
| 4295 RETURN_ON_FAILED_EXECUTION(Value); | 4320 RETURN_ON_FAILED_EXECUTION(Value); |
| 4296 if (!it.IsFound()) return MaybeLocal<Value>(); | 4321 if (!it.IsFound()) return MaybeLocal<Value>(); |
| 4297 RETURN_ESCAPED(result); | 4322 RETURN_ESCAPED(result); |
| 4298 } | 4323 } |
| 4299 | 4324 |
| 4300 | 4325 |
| 4301 Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) { | 4326 Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) { |
| 4302 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4327 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4303 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); | 4328 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); |
| 4304 } | 4329 } |
| 4305 | 4330 |
| 4306 | 4331 |
| 4307 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4332 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
| 4308 Local<Context> context, Local<Name> key) { | 4333 Local<Context> context, Local<Name> key) { |
| 4309 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4334 PREPARE_FOR_EXECUTION_PRIMITIVE( |
| 4310 context, "v8::Object::GetRealNamedPropertyAttributes()", | 4335 context, v8_Object_GetRealNamedPropertyAttributes, |
| 4311 PropertyAttribute); | 4336 "v8::Object::GetRealNamedPropertyAttributes", PropertyAttribute); |
| 4312 auto self = Utils::OpenHandle(this); | 4337 auto self = Utils::OpenHandle(this); |
| 4313 auto key_obj = Utils::OpenHandle(*key); | 4338 auto key_obj = Utils::OpenHandle(*key); |
| 4314 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4339 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
| 4315 isolate, self, key_obj, self, | 4340 isolate, self, key_obj, self, |
| 4316 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4341 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| 4317 auto result = i::JSReceiver::GetPropertyAttributes(&it); | 4342 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
| 4318 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4343 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
| 4319 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4344 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
| 4320 if (result.FromJust() == i::ABSENT) { | 4345 if (result.FromJust() == i::ABSENT) { |
| 4321 return Just(static_cast<PropertyAttribute>(i::NONE)); | 4346 return Just(static_cast<PropertyAttribute>(i::NONE)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4412 | 4437 |
| 4413 bool v8::Object::IsCallable() { | 4438 bool v8::Object::IsCallable() { |
| 4414 auto self = Utils::OpenHandle(this); | 4439 auto self = Utils::OpenHandle(this); |
| 4415 return self->IsCallable(); | 4440 return self->IsCallable(); |
| 4416 } | 4441 } |
| 4417 | 4442 |
| 4418 | 4443 |
| 4419 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4444 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
| 4420 Local<Value> recv, int argc, | 4445 Local<Value> recv, int argc, |
| 4421 Local<Value> argv[]) { | 4446 Local<Value> argv[]) { |
| 4422 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4447 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, v8_Object_CallAsFunction, |
| 4423 Value); | 4448 "v8::Object::CallAsFunction", Value); |
| 4424 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4449 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4425 TRACE_EVENT0("v8", "V8.Execute"); | 4450 TRACE_EVENT0("v8", "V8.Execute"); |
| 4426 auto self = Utils::OpenHandle(this); | 4451 auto self = Utils::OpenHandle(this); |
| 4427 auto recv_obj = Utils::OpenHandle(*recv); | 4452 auto recv_obj = Utils::OpenHandle(*recv); |
| 4428 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4453 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4429 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4454 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4430 Local<Value> result; | 4455 Local<Value> result; |
| 4431 has_pending_exception = !ToLocal<Value>( | 4456 has_pending_exception = !ToLocal<Value>( |
| 4432 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4457 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
| 4433 RETURN_ON_FAILED_EXECUTION(Value); | 4458 RETURN_ON_FAILED_EXECUTION(Value); |
| 4434 RETURN_ESCAPED(result); | 4459 RETURN_ESCAPED(result); |
| 4435 } | 4460 } |
| 4436 | 4461 |
| 4437 | 4462 |
| 4438 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, | 4463 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
| 4439 v8::Local<v8::Value> argv[]) { | 4464 v8::Local<v8::Value> argv[]) { |
| 4440 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4465 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4441 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4466 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4442 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4467 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
| 4443 Value); | 4468 Value); |
| 4444 } | 4469 } |
| 4445 | 4470 |
| 4446 | 4471 |
| 4447 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4472 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
| 4448 Local<Value> argv[]) { | 4473 Local<Value> argv[]) { |
| 4449 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4474 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, v8_Object_CallAsConstructor, |
| 4450 "v8::Object::CallAsConstructor()", Value); | 4475 "v8::Object::CallAsConstructor", Value); |
| 4451 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4476 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4452 TRACE_EVENT0("v8", "V8.Execute"); | 4477 TRACE_EVENT0("v8", "V8.Execute"); |
| 4453 auto self = Utils::OpenHandle(this); | 4478 auto self = Utils::OpenHandle(this); |
| 4454 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4479 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4455 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4480 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4456 Local<Value> result; | 4481 Local<Value> result; |
| 4457 has_pending_exception = !ToLocal<Value>( | 4482 has_pending_exception = !ToLocal<Value>( |
| 4458 i::Execution::New(isolate, self, self, argc, args), &result); | 4483 i::Execution::New(isolate, self, self, argc, args), &result); |
| 4459 RETURN_ON_FAILED_EXECUTION(Value); | 4484 RETURN_ON_FAILED_EXECUTION(Value); |
| 4460 RETURN_ESCAPED(result); | 4485 RETURN_ESCAPED(result); |
| 4461 } | 4486 } |
| 4462 | 4487 |
| 4463 | 4488 |
| 4464 Local<v8::Value> Object::CallAsConstructor(int argc, | 4489 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 4465 v8::Local<v8::Value> argv[]) { | 4490 v8::Local<v8::Value> argv[]) { |
| 4466 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4491 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4467 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4492 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
| 4468 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4493 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
| 4469 } | 4494 } |
| 4470 | 4495 |
| 4471 | 4496 |
| 4472 MaybeLocal<Function> Function::New(Local<Context> context, | 4497 MaybeLocal<Function> Function::New(Local<Context> context, |
| 4473 FunctionCallback callback, Local<Value> data, | 4498 FunctionCallback callback, Local<Value> data, |
| 4474 int length) { | 4499 int length) { |
| 4475 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); | 4500 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); |
| 4476 LOG_API(isolate, "Function::New"); | 4501 LOG_API(isolate, Function_New, "Function::New"); |
| 4477 ENTER_V8(isolate); | 4502 ENTER_V8(isolate); |
| 4478 return FunctionTemplateNew(isolate, callback, nullptr, data, | 4503 return FunctionTemplateNew(isolate, callback, nullptr, data, |
| 4479 Local<Signature>(), length, true) | 4504 Local<Signature>(), length, true) |
| 4480 ->GetFunction(context); | 4505 ->GetFunction(context); |
| 4481 } | 4506 } |
| 4482 | 4507 |
| 4483 | 4508 |
| 4484 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, | 4509 Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback, |
| 4485 Local<Value> data, int length) { | 4510 Local<Value> data, int length) { |
| 4486 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) | 4511 return Function::New(v8_isolate->GetCurrentContext(), callback, data, length) |
| 4487 .FromMaybe(Local<Function>()); | 4512 .FromMaybe(Local<Function>()); |
| 4488 } | 4513 } |
| 4489 | 4514 |
| 4490 | 4515 |
| 4491 Local<v8::Object> Function::NewInstance() const { | 4516 Local<v8::Object> Function::NewInstance() const { |
| 4492 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4517 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
| 4493 .FromMaybe(Local<Object>()); | 4518 .FromMaybe(Local<Object>()); |
| 4494 } | 4519 } |
| 4495 | 4520 |
| 4496 | 4521 |
| 4497 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, | 4522 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, |
| 4498 v8::Local<v8::Value> argv[]) const { | 4523 v8::Local<v8::Value> argv[]) const { |
| 4499 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", | 4524 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, v8_Function_NewInstance, |
| 4500 Object); | 4525 "v8::Function::NewInstance", Object); |
| 4501 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4526 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4502 TRACE_EVENT0("v8", "V8.Execute"); | 4527 TRACE_EVENT0("v8", "V8.Execute"); |
| 4503 auto self = Utils::OpenHandle(this); | 4528 auto self = Utils::OpenHandle(this); |
| 4504 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4529 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4505 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4530 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4506 Local<Object> result; | 4531 Local<Object> result; |
| 4507 has_pending_exception = !ToLocal<Object>( | 4532 has_pending_exception = !ToLocal<Object>( |
| 4508 i::Execution::New(isolate, self, self, argc, args), &result); | 4533 i::Execution::New(isolate, self, self, argc, args), &result); |
| 4509 RETURN_ON_FAILED_EXECUTION(Object); | 4534 RETURN_ON_FAILED_EXECUTION(Object); |
| 4510 RETURN_ESCAPED(result); | 4535 RETURN_ESCAPED(result); |
| 4511 } | 4536 } |
| 4512 | 4537 |
| 4513 | 4538 |
| 4514 Local<v8::Object> Function::NewInstance(int argc, | 4539 Local<v8::Object> Function::NewInstance(int argc, |
| 4515 v8::Local<v8::Value> argv[]) const { | 4540 v8::Local<v8::Value> argv[]) const { |
| 4516 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4541 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 4517 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); | 4542 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); |
| 4518 } | 4543 } |
| 4519 | 4544 |
| 4520 | 4545 |
| 4521 MaybeLocal<v8::Value> Function::Call(Local<Context> context, | 4546 MaybeLocal<v8::Value> Function::Call(Local<Context> context, |
| 4522 v8::Local<v8::Value> recv, int argc, | 4547 v8::Local<v8::Value> recv, int argc, |
| 4523 v8::Local<v8::Value> argv[]) { | 4548 v8::Local<v8::Value> argv[]) { |
| 4524 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); | 4549 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, v8_Function_Call, |
| 4550 "v8::Function::Call", Value); | |
| 4525 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4551 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 4526 TRACE_EVENT0("v8", "V8.Execute"); | 4552 TRACE_EVENT0("v8", "V8.Execute"); |
| 4527 auto self = Utils::OpenHandle(this); | 4553 auto self = Utils::OpenHandle(this); |
| 4528 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4554 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
| 4529 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); | 4555 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
| 4530 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4556 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4531 Local<Value> result; | 4557 Local<Value> result; |
| 4532 has_pending_exception = !ToLocal<Value>( | 4558 has_pending_exception = !ToLocal<Value>( |
| 4533 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); | 4559 i::Execution::Call(isolate, self, recv_obj, argc, args), &result); |
| 4534 RETURN_ON_FAILED_EXECUTION(Value); | 4560 RETURN_ON_FAILED_EXECUTION(Value); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5227 } | 5253 } |
| 5228 return true; | 5254 return true; |
| 5229 } | 5255 } |
| 5230 | 5256 |
| 5231 | 5257 |
| 5232 int String::WriteUtf8(char* buffer, | 5258 int String::WriteUtf8(char* buffer, |
| 5233 int capacity, | 5259 int capacity, |
| 5234 int* nchars_ref, | 5260 int* nchars_ref, |
| 5235 int options) const { | 5261 int options) const { |
| 5236 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 5262 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 5237 LOG_API(isolate, "String::WriteUtf8"); | 5263 LOG_API(isolate, String_WriteUtf8, "String::WriteUtf8"); |
| 5238 ENTER_V8(isolate); | 5264 ENTER_V8(isolate); |
| 5239 i::Handle<i::String> str = Utils::OpenHandle(this); | 5265 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 5240 if (options & HINT_MANY_WRITES_EXPECTED) { | 5266 if (options & HINT_MANY_WRITES_EXPECTED) { |
| 5241 str = i::String::Flatten(str); // Flatten the string for efficiency. | 5267 str = i::String::Flatten(str); // Flatten the string for efficiency. |
| 5242 } | 5268 } |
| 5243 const int string_length = str->length(); | 5269 const int string_length = str->length(); |
| 5244 bool write_null = !(options & NO_NULL_TERMINATION); | 5270 bool write_null = !(options & NO_NULL_TERMINATION); |
| 5245 bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8); | 5271 bool replace_invalid_utf8 = (options & REPLACE_INVALID_UTF8); |
| 5246 int max16BitCodeUnitSize = unibrow::Utf8::kMax16BitCodeUnitSize; | 5272 int max16BitCodeUnitSize = unibrow::Utf8::kMax16BitCodeUnitSize; |
| 5247 // First check if we can just write the string without checking capacity. | 5273 // 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... | |
| 5280 } | 5306 } |
| 5281 | 5307 |
| 5282 | 5308 |
| 5283 template<typename CharType> | 5309 template<typename CharType> |
| 5284 static inline int WriteHelper(const String* string, | 5310 static inline int WriteHelper(const String* string, |
| 5285 CharType* buffer, | 5311 CharType* buffer, |
| 5286 int start, | 5312 int start, |
| 5287 int length, | 5313 int length, |
| 5288 int options) { | 5314 int options) { |
| 5289 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); | 5315 i::Isolate* isolate = Utils::OpenHandle(string)->GetIsolate(); |
| 5290 LOG_API(isolate, "String::Write"); | 5316 LOG_API(isolate, String_Write, "String::Write"); |
| 5291 ENTER_V8(isolate); | 5317 ENTER_V8(isolate); |
| 5292 DCHECK(start >= 0 && length >= -1); | 5318 DCHECK(start >= 0 && length >= -1); |
| 5293 i::Handle<i::String> str = Utils::OpenHandle(string); | 5319 i::Handle<i::String> str = Utils::OpenHandle(string); |
| 5294 if (options & String::HINT_MANY_WRITES_EXPECTED) { | 5320 if (options & String::HINT_MANY_WRITES_EXPECTED) { |
| 5295 // Flatten the string for efficiency. This applies whether we are | 5321 // Flatten the string for efficiency. This applies whether we are |
| 5296 // using StringCharacterStream or Get(i) to access the characters. | 5322 // using StringCharacterStream or Get(i) to access the characters. |
| 5297 str = i::String::Flatten(str); | 5323 str = i::String::Flatten(str); |
| 5298 } | 5324 } |
| 5299 int end = start + length; | 5325 int end = start + length; |
| 5300 if ((length == -1) || (length > str->length() - start) ) | 5326 if ((length == -1) || (length > str->length() - start) ) |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5654 // Leave V8. | 5680 // Leave V8. |
| 5655 | 5681 |
| 5656 return env; | 5682 return env; |
| 5657 } | 5683 } |
| 5658 | 5684 |
| 5659 Local<Context> v8::Context::New(v8::Isolate* external_isolate, | 5685 Local<Context> v8::Context::New(v8::Isolate* external_isolate, |
| 5660 v8::ExtensionConfiguration* extensions, | 5686 v8::ExtensionConfiguration* extensions, |
| 5661 v8::Local<ObjectTemplate> global_template, | 5687 v8::Local<ObjectTemplate> global_template, |
| 5662 v8::Local<Value> global_object) { | 5688 v8::Local<Value> global_object) { |
| 5663 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 5689 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
| 5664 LOG_API(isolate, "Context::New"); | 5690 LOG_API(isolate, Context_New, "Context::New"); |
| 5665 i::HandleScope scope(isolate); | 5691 i::HandleScope scope(isolate); |
| 5666 ExtensionConfiguration no_extensions; | 5692 ExtensionConfiguration no_extensions; |
| 5667 if (extensions == NULL) extensions = &no_extensions; | 5693 if (extensions == NULL) extensions = &no_extensions; |
| 5668 i::Handle<i::Context> env = | 5694 i::Handle<i::Context> env = |
| 5669 CreateEnvironment(isolate, extensions, global_template, global_object); | 5695 CreateEnvironment(isolate, extensions, global_template, global_object); |
| 5670 if (env.is_null()) { | 5696 if (env.is_null()) { |
| 5671 if (isolate->has_pending_exception()) { | 5697 if (isolate->has_pending_exception()) { |
| 5672 isolate->OptionalRescheduleException(true); | 5698 isolate->OptionalRescheduleException(true); |
| 5673 } | 5699 } |
| 5674 return Local<Context>(); | 5700 return Local<Context>(); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5757 } | 5783 } |
| 5758 | 5784 |
| 5759 | 5785 |
| 5760 size_t Context::EstimatedSize() { | 5786 size_t Context::EstimatedSize() { |
| 5761 return static_cast<size_t>( | 5787 return static_cast<size_t>( |
| 5762 i::ContextMeasure(*Utils::OpenHandle(this)).Size()); | 5788 i::ContextMeasure(*Utils::OpenHandle(this)).Size()); |
| 5763 } | 5789 } |
| 5764 | 5790 |
| 5765 | 5791 |
| 5766 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { | 5792 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { |
| 5767 PREPARE_FOR_EXECUTION(context, "v8::ObjectTemplate::NewInstance()", Object); | 5793 PREPARE_FOR_EXECUTION(context, v8_ObjectTemplate_NewInstance, |
| 5794 "v8::ObjectTemplate::NewInstance", Object); | |
| 5768 auto self = Utils::OpenHandle(this); | 5795 auto self = Utils::OpenHandle(this); |
| 5769 Local<Object> result; | 5796 Local<Object> result; |
| 5770 has_pending_exception = | 5797 has_pending_exception = |
| 5771 !ToLocal<Object>(i::ApiNatives::InstantiateObject(self), &result); | 5798 !ToLocal<Object>(i::ApiNatives::InstantiateObject(self), &result); |
| 5772 RETURN_ON_FAILED_EXECUTION(Object); | 5799 RETURN_ON_FAILED_EXECUTION(Object); |
| 5773 RETURN_ESCAPED(result); | 5800 RETURN_ESCAPED(result); |
| 5774 } | 5801 } |
| 5775 | 5802 |
| 5776 | 5803 |
| 5777 Local<v8::Object> ObjectTemplate::NewInstance() { | 5804 Local<v8::Object> ObjectTemplate::NewInstance() { |
| 5778 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 5805 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 5779 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context), Object); | 5806 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context), Object); |
| 5780 } | 5807 } |
| 5781 | 5808 |
| 5782 | 5809 |
| 5783 MaybeLocal<v8::Function> FunctionTemplate::GetFunction(Local<Context> context) { | 5810 MaybeLocal<v8::Function> FunctionTemplate::GetFunction(Local<Context> context) { |
| 5784 PREPARE_FOR_EXECUTION(context, "v8::FunctionTemplate::GetFunction()", | 5811 PREPARE_FOR_EXECUTION(context, v8_FunctionTemplate_GetFunction, |
| 5785 Function); | 5812 "v8::FunctionTemplate::GetFunction", Function); |
| 5786 auto self = Utils::OpenHandle(this); | 5813 auto self = Utils::OpenHandle(this); |
| 5787 Local<Function> result; | 5814 Local<Function> result; |
| 5788 has_pending_exception = | 5815 has_pending_exception = |
| 5789 !ToLocal<Function>(i::ApiNatives::InstantiateFunction(self), &result); | 5816 !ToLocal<Function>(i::ApiNatives::InstantiateFunction(self), &result); |
| 5790 RETURN_ON_FAILED_EXECUTION(Function); | 5817 RETURN_ON_FAILED_EXECUTION(Function); |
| 5791 RETURN_ESCAPED(result); | 5818 RETURN_ESCAPED(result); |
| 5792 } | 5819 } |
| 5793 | 5820 |
| 5794 | 5821 |
| 5795 Local<v8::Function> FunctionTemplate::GetFunction() { | 5822 Local<v8::Function> FunctionTemplate::GetFunction() { |
| 5796 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 5823 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 5797 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); | 5824 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); |
| 5798 } | 5825 } |
| 5799 | 5826 |
| 5800 | 5827 |
| 5801 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { | 5828 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { |
| 5802 auto self = Utils::OpenHandle(this); | 5829 auto self = Utils::OpenHandle(this); |
| 5803 auto obj = Utils::OpenHandle(*value); | 5830 auto obj = Utils::OpenHandle(*value); |
| 5804 return self->IsTemplateFor(*obj); | 5831 return self->IsTemplateFor(*obj); |
| 5805 } | 5832 } |
| 5806 | 5833 |
| 5807 | 5834 |
| 5808 Local<External> v8::External::New(Isolate* isolate, void* value) { | 5835 Local<External> v8::External::New(Isolate* isolate, void* value) { |
| 5809 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5836 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
| 5810 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5837 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5811 LOG_API(i_isolate, "External::New"); | 5838 LOG_API(i_isolate, External_New, "External::New"); |
| 5812 ENTER_V8(i_isolate); | 5839 ENTER_V8(i_isolate); |
| 5813 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); | 5840 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); |
| 5814 return Utils::ExternalToLocal(external); | 5841 return Utils::ExternalToLocal(external); |
| 5815 } | 5842 } |
| 5816 | 5843 |
| 5817 | 5844 |
| 5818 void* External::Value() const { | 5845 void* External::Value() const { |
| 5819 return ExternalValue(*Utils::OpenHandle(this)); | 5846 return ExternalValue(*Utils::OpenHandle(this)); |
| 5820 } | 5847 } |
| 5821 | 5848 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5869 i::Vector<const uint16_t> string) { | 5896 i::Vector<const uint16_t> string) { |
| 5870 if (type == v8::NewStringType::kInternalized) { | 5897 if (type == v8::NewStringType::kInternalized) { |
| 5871 return factory->InternalizeTwoByteString(string); | 5898 return factory->InternalizeTwoByteString(string); |
| 5872 } | 5899 } |
| 5873 return factory->NewStringFromTwoByte(string); | 5900 return factory->NewStringFromTwoByte(string); |
| 5874 } | 5901 } |
| 5875 | 5902 |
| 5876 | 5903 |
| 5877 STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength); | 5904 STATIC_ASSERT(v8::String::kMaxLength == i::String::kMaxLength); |
| 5878 | 5905 |
| 5879 | |
| 5880 template <typename Char> | |
| 5881 inline MaybeLocal<String> NewString(Isolate* v8_isolate, const char* location, | |
| 5882 const char* env, const Char* data, | |
| 5883 v8::NewStringType type, int length) { | |
| 5884 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | |
| 5885 if (length == 0) return String::Empty(v8_isolate); | |
| 5886 // TODO(dcarney): throw a context free exception. | |
| 5887 if (length > i::String::kMaxLength) return MaybeLocal<String>(); | |
| 5888 ENTER_V8(isolate); | |
| 5889 LOG_API(isolate, env); | |
| 5890 if (length < 0) length = StringLength(data); | |
| 5891 i::Handle<i::String> result = | |
| 5892 NewString(isolate->factory(), type, i::Vector<const Char>(data, length)) | |
| 5893 .ToHandleChecked(); | |
| 5894 return Utils::ToLocal(result); | |
| 5895 } | |
| 5896 | |
| 5897 } // anonymous namespace | 5906 } // anonymous namespace |
| 5898 | 5907 |
| 5908 // TODO(dcarney): throw a context free exception. | |
| 5909 #define NEW_STRING(isolate, counter_name, function_name, Char, data, type, \ | |
| 5910 length) \ | |
| 5911 MaybeLocal<String> result; \ | |
| 5912 if (length == 0) { \ | |
| 5913 result = String::Empty(isolate); \ | |
| 5914 } else if (length > i::String::kMaxLength) { \ | |
| 5915 result = MaybeLocal<String>(); \ | |
| 5916 } else { \ | |
| 5917 i::Isolate* i_isolate = reinterpret_cast<internal::Isolate*>(isolate); \ | |
| 5918 ENTER_V8(i_isolate); \ | |
| 5919 LOG_API(i_isolate, counter_name, function_name); \ | |
| 5920 if (length < 0) length = StringLength(data); \ | |
| 5921 i::Handle<i::String> handle_result = \ | |
| 5922 NewString(i_isolate->factory(), type, \ | |
| 5923 i::Vector<const Char>(data, length)) \ | |
| 5924 .ToHandleChecked(); \ | |
| 5925 result = Utils::ToLocal(handle_result); \ | |
| 5926 } | |
| 5899 | 5927 |
| 5900 Local<String> String::NewFromUtf8(Isolate* isolate, | 5928 Local<String> String::NewFromUtf8(Isolate* isolate, |
| 5901 const char* data, | 5929 const char* data, |
| 5902 NewStringType type, | 5930 NewStringType type, |
| 5903 int length) { | 5931 int length) { |
| 5904 RETURN_TO_LOCAL_UNCHECKED( | 5932 NEW_STRING(isolate, String_NewFromUtf8, "v8::String::NewFromUtf8", char, data, |
| 5905 NewString(isolate, "v8::String::NewFromUtf8()", "String::NewFromUtf8", | 5933 static_cast<v8::NewStringType>(type), length); |
| 5906 data, static_cast<v8::NewStringType>(type), length), | 5934 RETURN_TO_LOCAL_UNCHECKED(result, String); |
| 5907 String); | |
| 5908 } | 5935 } |
| 5909 | 5936 |
| 5910 | 5937 |
| 5911 MaybeLocal<String> String::NewFromUtf8(Isolate* isolate, const char* data, | 5938 MaybeLocal<String> String::NewFromUtf8(Isolate* isolate, const char* data, |
| 5912 v8::NewStringType type, int length) { | 5939 v8::NewStringType type, int length) { |
| 5913 return NewString(isolate, "v8::String::NewFromUtf8()", "String::NewFromUtf8", | 5940 NEW_STRING(isolate, String_NewFromUtf8, "v8::String::NewFromUtf8", char, data, |
| 5914 data, type, length); | 5941 type, length); |
| 5942 return result; | |
| 5915 } | 5943 } |
| 5916 | 5944 |
| 5917 | 5945 |
| 5918 Local<String> String::NewFromOneByte(Isolate* isolate, | 5946 Local<String> String::NewFromOneByte(Isolate* isolate, |
| 5919 const uint8_t* data, | 5947 const uint8_t* data, |
| 5920 NewStringType type, | 5948 NewStringType type, |
| 5921 int length) { | 5949 int length) { |
| 5922 RETURN_TO_LOCAL_UNCHECKED( | 5950 NEW_STRING(isolate, String_NewFromOneByte, "v8::String::NewFromOneByte", |
| 5923 NewString(isolate, "v8::String::NewFromOneByte()", | 5951 uint8_t, data, static_cast<v8::NewStringType>(type), length); |
| 5924 "String::NewFromOneByte", data, | 5952 RETURN_TO_LOCAL_UNCHECKED(result, String); |
| 5925 static_cast<v8::NewStringType>(type), length), | |
| 5926 String); | |
| 5927 } | 5953 } |
| 5928 | 5954 |
| 5929 | 5955 |
| 5930 MaybeLocal<String> String::NewFromOneByte(Isolate* isolate, const uint8_t* data, | 5956 MaybeLocal<String> String::NewFromOneByte(Isolate* isolate, const uint8_t* data, |
| 5931 v8::NewStringType type, int length) { | 5957 v8::NewStringType type, int length) { |
| 5932 return NewString(isolate, "v8::String::NewFromOneByte()", | 5958 NEW_STRING(isolate, String_NewFromOneByte, "v8::String::NewFromOneByte", |
| 5933 "String::NewFromOneByte", data, type, length); | 5959 uint8_t, data, type, length); |
| 5960 return result; | |
| 5934 } | 5961 } |
| 5935 | 5962 |
| 5936 | 5963 |
| 5937 Local<String> String::NewFromTwoByte(Isolate* isolate, | 5964 Local<String> String::NewFromTwoByte(Isolate* isolate, |
| 5938 const uint16_t* data, | 5965 const uint16_t* data, |
| 5939 NewStringType type, | 5966 NewStringType type, |
| 5940 int length) { | 5967 int length) { |
| 5941 RETURN_TO_LOCAL_UNCHECKED( | 5968 NEW_STRING(isolate, String_NewFromTwoByte, "v8::String::NewFromTwoByte", |
| 5942 NewString(isolate, "v8::String::NewFromTwoByte()", | 5969 uint16_t, data, static_cast<v8::NewStringType>(type), length); |
| 5943 "String::NewFromTwoByte", data, | 5970 RETURN_TO_LOCAL_UNCHECKED(result, String); |
| 5944 static_cast<v8::NewStringType>(type), length), | |
| 5945 String); | |
| 5946 } | 5971 } |
| 5947 | 5972 |
| 5948 | 5973 |
| 5949 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, | 5974 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, |
| 5950 const uint16_t* data, | 5975 const uint16_t* data, |
| 5951 v8::NewStringType type, int length) { | 5976 v8::NewStringType type, int length) { |
| 5952 return NewString(isolate, "v8::String::NewFromTwoByte()", | 5977 NEW_STRING(isolate, String_NewFromTwoByte, "v8::String::NewFromTwoByte", |
| 5953 "String::NewFromTwoByte", data, type, length); | 5978 uint16_t, data, type, length); |
| 5979 return result; | |
| 5954 } | 5980 } |
| 5955 | 5981 |
| 5956 | 5982 |
| 5957 Local<String> v8::String::Concat(Local<String> left, Local<String> right) { | 5983 Local<String> v8::String::Concat(Local<String> left, Local<String> right) { |
| 5958 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5984 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
| 5959 i::Isolate* isolate = left_string->GetIsolate(); | 5985 i::Isolate* isolate = left_string->GetIsolate(); |
| 5960 ENTER_V8(isolate); | 5986 ENTER_V8(isolate); |
| 5961 LOG_API(isolate, "v8::String::Concat"); | 5987 LOG_API(isolate, v8_String_Concat, "v8::String::Concat"); |
| 5962 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5988 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
| 5963 // If we are steering towards a range error, do not wait for the error to be | 5989 // If we are steering towards a range error, do not wait for the error to be |
| 5964 // thrown, and return the null handle instead. | 5990 // thrown, and return the null handle instead. |
| 5965 if (left_string->length() + right_string->length() > i::String::kMaxLength) { | 5991 if (left_string->length() + right_string->length() > i::String::kMaxLength) { |
| 5966 return Local<String>(); | 5992 return Local<String>(); |
| 5967 } | 5993 } |
| 5968 i::Handle<i::String> result = isolate->factory()->NewConsString( | 5994 i::Handle<i::String> result = isolate->factory()->NewConsString( |
| 5969 left_string, right_string).ToHandleChecked(); | 5995 left_string, right_string).ToHandleChecked(); |
| 5970 return Utils::ToLocal(result); | 5996 return Utils::ToLocal(result); |
| 5971 } | 5997 } |
| 5972 | 5998 |
| 5973 | 5999 |
| 5974 MaybeLocal<String> v8::String::NewExternalTwoByte( | 6000 MaybeLocal<String> v8::String::NewExternalTwoByte( |
| 5975 Isolate* isolate, v8::String::ExternalStringResource* resource) { | 6001 Isolate* isolate, v8::String::ExternalStringResource* resource) { |
| 5976 CHECK(resource && resource->data()); | 6002 CHECK(resource && resource->data()); |
| 5977 // TODO(dcarney): throw a context free exception. | 6003 // TODO(dcarney): throw a context free exception. |
| 5978 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { | 6004 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { |
| 5979 return MaybeLocal<String>(); | 6005 return MaybeLocal<String>(); |
| 5980 } | 6006 } |
| 5981 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6007 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5982 ENTER_V8(i_isolate); | 6008 ENTER_V8(i_isolate); |
| 5983 LOG_API(i_isolate, "String::NewExternalTwoByte"); | 6009 LOG_API(i_isolate, String_NewExternalTwoByte, "String::NewExternalTwoByte"); |
| 5984 i::Handle<i::String> string = i_isolate->factory() | 6010 i::Handle<i::String> string = i_isolate->factory() |
| 5985 ->NewExternalStringFromTwoByte(resource) | 6011 ->NewExternalStringFromTwoByte(resource) |
| 5986 .ToHandleChecked(); | 6012 .ToHandleChecked(); |
| 5987 i_isolate->heap()->RegisterExternalString(*string); | 6013 i_isolate->heap()->RegisterExternalString(*string); |
| 5988 return Utils::ToLocal(string); | 6014 return Utils::ToLocal(string); |
| 5989 } | 6015 } |
| 5990 | 6016 |
| 5991 | 6017 |
| 5992 Local<String> v8::String::NewExternal( | 6018 Local<String> v8::String::NewExternal( |
| 5993 Isolate* isolate, v8::String::ExternalStringResource* resource) { | 6019 Isolate* isolate, v8::String::ExternalStringResource* resource) { |
| 5994 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String); | 6020 RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String); |
| 5995 } | 6021 } |
| 5996 | 6022 |
| 5997 | 6023 |
| 5998 MaybeLocal<String> v8::String::NewExternalOneByte( | 6024 MaybeLocal<String> v8::String::NewExternalOneByte( |
| 5999 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { | 6025 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { |
| 6000 CHECK(resource && resource->data()); | 6026 CHECK(resource && resource->data()); |
| 6001 // TODO(dcarney): throw a context free exception. | 6027 // TODO(dcarney): throw a context free exception. |
| 6002 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { | 6028 if (resource->length() > static_cast<size_t>(i::String::kMaxLength)) { |
| 6003 return MaybeLocal<String>(); | 6029 return MaybeLocal<String>(); |
| 6004 } | 6030 } |
| 6005 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6031 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6006 ENTER_V8(i_isolate); | 6032 ENTER_V8(i_isolate); |
| 6007 LOG_API(i_isolate, "String::NewExternalOneByte"); | 6033 LOG_API(i_isolate, String_NewExternalOneByte, "String::NewExternalOneByte"); |
| 6008 i::Handle<i::String> string = i_isolate->factory() | 6034 i::Handle<i::String> string = i_isolate->factory() |
| 6009 ->NewExternalStringFromOneByte(resource) | 6035 ->NewExternalStringFromOneByte(resource) |
| 6010 .ToHandleChecked(); | 6036 .ToHandleChecked(); |
| 6011 i_isolate->heap()->RegisterExternalString(*string); | 6037 i_isolate->heap()->RegisterExternalString(*string); |
| 6012 return Utils::ToLocal(string); | 6038 return Utils::ToLocal(string); |
| 6013 } | 6039 } |
| 6014 | 6040 |
| 6015 | 6041 |
| 6016 Local<String> v8::String::NewExternal( | 6042 Local<String> v8::String::NewExternal( |
| 6017 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { | 6043 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6080 | 6106 |
| 6081 | 6107 |
| 6082 Isolate* v8::Object::GetIsolate() { | 6108 Isolate* v8::Object::GetIsolate() { |
| 6083 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 6109 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 6084 return reinterpret_cast<Isolate*>(i_isolate); | 6110 return reinterpret_cast<Isolate*>(i_isolate); |
| 6085 } | 6111 } |
| 6086 | 6112 |
| 6087 | 6113 |
| 6088 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 6114 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
| 6089 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6115 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6090 LOG_API(i_isolate, "Object::New"); | 6116 LOG_API(i_isolate, Object_New, "Object::New"); |
| 6091 ENTER_V8(i_isolate); | 6117 ENTER_V8(i_isolate); |
| 6092 i::Handle<i::JSObject> obj = | 6118 i::Handle<i::JSObject> obj = |
| 6093 i_isolate->factory()->NewJSObject(i_isolate->object_function()); | 6119 i_isolate->factory()->NewJSObject(i_isolate->object_function()); |
| 6094 return Utils::ToLocal(obj); | 6120 return Utils::ToLocal(obj); |
| 6095 } | 6121 } |
| 6096 | 6122 |
| 6097 | 6123 |
| 6098 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { | 6124 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { |
| 6099 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6125 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6100 LOG_API(i_isolate, "NumberObject::New"); | 6126 LOG_API(i_isolate, NumberObject_New, "NumberObject::New"); |
| 6101 ENTER_V8(i_isolate); | 6127 ENTER_V8(i_isolate); |
| 6102 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); | 6128 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
| 6103 i::Handle<i::Object> obj = | 6129 i::Handle<i::Object> obj = |
| 6104 i::Object::ToObject(i_isolate, number).ToHandleChecked(); | 6130 i::Object::ToObject(i_isolate, number).ToHandleChecked(); |
| 6105 return Utils::ToLocal(obj); | 6131 return Utils::ToLocal(obj); |
| 6106 } | 6132 } |
| 6107 | 6133 |
| 6108 | 6134 |
| 6109 double v8::NumberObject::ValueOf() const { | 6135 double v8::NumberObject::ValueOf() const { |
| 6110 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6136 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6111 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6137 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6112 i::Isolate* isolate = jsvalue->GetIsolate(); | 6138 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6113 LOG_API(isolate, "NumberObject::NumberValue"); | 6139 LOG_API(isolate, NumberObject_NumberValue, "NumberObject::NumberValue"); |
| 6114 return jsvalue->value()->Number(); | 6140 return jsvalue->value()->Number(); |
| 6115 } | 6141 } |
| 6116 | 6142 |
| 6117 | 6143 |
| 6118 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) { | 6144 Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) { |
| 6119 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6145 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6120 LOG_API(i_isolate, "BooleanObject::New"); | 6146 LOG_API(i_isolate, BooleanObject_New, "BooleanObject::New"); |
| 6121 ENTER_V8(i_isolate); | 6147 ENTER_V8(i_isolate); |
| 6122 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value() | 6148 i::Handle<i::Object> boolean(value ? i_isolate->heap()->true_value() |
| 6123 : i_isolate->heap()->false_value(), | 6149 : i_isolate->heap()->false_value(), |
| 6124 i_isolate); | 6150 i_isolate); |
| 6125 i::Handle<i::Object> obj = | 6151 i::Handle<i::Object> obj = |
| 6126 i::Object::ToObject(i_isolate, boolean).ToHandleChecked(); | 6152 i::Object::ToObject(i_isolate, boolean).ToHandleChecked(); |
| 6127 return Utils::ToLocal(obj); | 6153 return Utils::ToLocal(obj); |
| 6128 } | 6154 } |
| 6129 | 6155 |
| 6130 | 6156 |
| 6131 Local<v8::Value> v8::BooleanObject::New(bool value) { | 6157 Local<v8::Value> v8::BooleanObject::New(bool value) { |
| 6132 return New(Isolate::GetCurrent(), value); | 6158 return New(Isolate::GetCurrent(), value); |
| 6133 } | 6159 } |
| 6134 | 6160 |
| 6135 | 6161 |
| 6136 bool v8::BooleanObject::ValueOf() const { | 6162 bool v8::BooleanObject::ValueOf() const { |
| 6137 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6163 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6138 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6164 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6139 i::Isolate* isolate = jsvalue->GetIsolate(); | 6165 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6140 LOG_API(isolate, "BooleanObject::BooleanValue"); | 6166 LOG_API(isolate, BooleanObject_BooleanValue, "BooleanObject::BooleanValue"); |
| 6141 return jsvalue->value()->IsTrue(); | 6167 return jsvalue->value()->IsTrue(); |
| 6142 } | 6168 } |
| 6143 | 6169 |
| 6144 | 6170 |
| 6145 Local<v8::Value> v8::StringObject::New(Local<String> value) { | 6171 Local<v8::Value> v8::StringObject::New(Local<String> value) { |
| 6146 i::Handle<i::String> string = Utils::OpenHandle(*value); | 6172 i::Handle<i::String> string = Utils::OpenHandle(*value); |
| 6147 i::Isolate* isolate = string->GetIsolate(); | 6173 i::Isolate* isolate = string->GetIsolate(); |
| 6148 LOG_API(isolate, "StringObject::New"); | 6174 LOG_API(isolate, StringObject_New, "StringObject::New"); |
| 6149 ENTER_V8(isolate); | 6175 ENTER_V8(isolate); |
| 6150 i::Handle<i::Object> obj = | 6176 i::Handle<i::Object> obj = |
| 6151 i::Object::ToObject(isolate, string).ToHandleChecked(); | 6177 i::Object::ToObject(isolate, string).ToHandleChecked(); |
| 6152 return Utils::ToLocal(obj); | 6178 return Utils::ToLocal(obj); |
| 6153 } | 6179 } |
| 6154 | 6180 |
| 6155 | 6181 |
| 6156 Local<v8::String> v8::StringObject::ValueOf() const { | 6182 Local<v8::String> v8::StringObject::ValueOf() const { |
| 6157 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6183 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6158 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6184 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6159 i::Isolate* isolate = jsvalue->GetIsolate(); | 6185 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6160 LOG_API(isolate, "StringObject::StringValue"); | 6186 LOG_API(isolate, StringObject_StringValue, "StringObject::StringValue"); |
| 6161 return Utils::ToLocal( | 6187 return Utils::ToLocal( |
| 6162 i::Handle<i::String>(i::String::cast(jsvalue->value()))); | 6188 i::Handle<i::String>(i::String::cast(jsvalue->value()))); |
| 6163 } | 6189 } |
| 6164 | 6190 |
| 6165 | 6191 |
| 6166 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { | 6192 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { |
| 6167 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6193 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6168 LOG_API(i_isolate, "SymbolObject::New"); | 6194 LOG_API(i_isolate, SymbolObject_New, "SymbolObject::New"); |
| 6169 ENTER_V8(i_isolate); | 6195 ENTER_V8(i_isolate); |
| 6170 i::Handle<i::Object> obj = i::Object::ToObject( | 6196 i::Handle<i::Object> obj = i::Object::ToObject( |
| 6171 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); | 6197 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); |
| 6172 return Utils::ToLocal(obj); | 6198 return Utils::ToLocal(obj); |
| 6173 } | 6199 } |
| 6174 | 6200 |
| 6175 | 6201 |
| 6176 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 6202 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
| 6177 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6203 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6178 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 6204 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 6179 i::Isolate* isolate = jsvalue->GetIsolate(); | 6205 i::Isolate* isolate = jsvalue->GetIsolate(); |
| 6180 LOG_API(isolate, "SymbolObject::SymbolValue"); | 6206 LOG_API(isolate, SymbolObject_SymbolValue, "SymbolObject::SymbolValue"); |
| 6181 return Utils::ToLocal( | 6207 return Utils::ToLocal( |
| 6182 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 6208 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
| 6183 } | 6209 } |
| 6184 | 6210 |
| 6185 | 6211 |
| 6186 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { | 6212 MaybeLocal<v8::Value> v8::Date::New(Local<Context> context, double time) { |
| 6187 if (std::isnan(time)) { | 6213 if (std::isnan(time)) { |
| 6188 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 6214 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 6189 time = std::numeric_limits<double>::quiet_NaN(); | 6215 time = std::numeric_limits<double>::quiet_NaN(); |
| 6190 } | 6216 } |
| 6191 PREPARE_FOR_EXECUTION(context, "Date::New", Value); | 6217 PREPARE_FOR_EXECUTION(context, Date_New, "Date::New", Value); |
| 6192 Local<Value> result; | 6218 Local<Value> result; |
| 6193 has_pending_exception = !ToLocal<Value>( | 6219 has_pending_exception = !ToLocal<Value>( |
| 6194 i::JSDate::New(isolate->date_function(), isolate->date_function(), time), | 6220 i::JSDate::New(isolate->date_function(), isolate->date_function(), time), |
| 6195 &result); | 6221 &result); |
| 6196 RETURN_ON_FAILED_EXECUTION(Value); | 6222 RETURN_ON_FAILED_EXECUTION(Value); |
| 6197 RETURN_ESCAPED(result); | 6223 RETURN_ESCAPED(result); |
| 6198 } | 6224 } |
| 6199 | 6225 |
| 6200 | 6226 |
| 6201 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { | 6227 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { |
| 6202 auto context = isolate->GetCurrentContext(); | 6228 auto context = isolate->GetCurrentContext(); |
| 6203 RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value); | 6229 RETURN_TO_LOCAL_UNCHECKED(New(context, time), Value); |
| 6204 } | 6230 } |
| 6205 | 6231 |
| 6206 | 6232 |
| 6207 double v8::Date::ValueOf() const { | 6233 double v8::Date::ValueOf() const { |
| 6208 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 6234 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 6209 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 6235 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
| 6210 i::Isolate* isolate = jsdate->GetIsolate(); | 6236 i::Isolate* isolate = jsdate->GetIsolate(); |
| 6211 LOG_API(isolate, "Date::NumberValue"); | 6237 LOG_API(isolate, Date_NumberValue, "Date::NumberValue"); |
| 6212 return jsdate->value()->Number(); | 6238 return jsdate->value()->Number(); |
| 6213 } | 6239 } |
| 6214 | 6240 |
| 6215 | 6241 |
| 6216 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { | 6242 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
| 6217 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6243 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6218 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); | 6244 LOG_API(i_isolate, Date_DateTimeConfigurationChangeNotification, |
| 6245 "Date::DateTimeConfigurationChangeNotification"); | |
| 6219 ENTER_V8(i_isolate); | 6246 ENTER_V8(i_isolate); |
| 6220 i_isolate->date_cache()->ResetDateCache(); | 6247 i_isolate->date_cache()->ResetDateCache(); |
| 6221 if (!i_isolate->eternal_handles()->Exists( | 6248 if (!i_isolate->eternal_handles()->Exists( |
| 6222 i::EternalHandles::DATE_CACHE_VERSION)) { | 6249 i::EternalHandles::DATE_CACHE_VERSION)) { |
| 6223 return; | 6250 return; |
| 6224 } | 6251 } |
| 6225 i::Handle<i::FixedArray> date_cache_version = | 6252 i::Handle<i::FixedArray> date_cache_version = |
| 6226 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( | 6253 i::Handle<i::FixedArray>::cast(i_isolate->eternal_handles()->GetSingleton( |
| 6227 i::EternalHandles::DATE_CACHE_VERSION)); | 6254 i::EternalHandles::DATE_CACHE_VERSION)); |
| 6228 DCHECK_EQ(1, date_cache_version->length()); | 6255 DCHECK_EQ(1, date_cache_version->length()); |
| 6229 CHECK(date_cache_version->get(0)->IsSmi()); | 6256 CHECK(date_cache_version->get(0)->IsSmi()); |
| 6230 date_cache_version->set( | 6257 date_cache_version->set( |
| 6231 0, | 6258 0, |
| 6232 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); | 6259 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); |
| 6233 } | 6260 } |
| 6234 | 6261 |
| 6235 | 6262 |
| 6236 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, | 6263 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, |
| 6237 Local<String> pattern, Flags flags) { | 6264 Local<String> pattern, Flags flags) { |
| 6238 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); | 6265 PREPARE_FOR_EXECUTION(context, RegExp_New, "RegExp::New", RegExp); |
| 6239 Local<v8::RegExp> result; | 6266 Local<v8::RegExp> result; |
| 6240 has_pending_exception = | 6267 has_pending_exception = |
| 6241 !ToLocal<RegExp>(i::JSRegExp::New(Utils::OpenHandle(*pattern), | 6268 !ToLocal<RegExp>(i::JSRegExp::New(Utils::OpenHandle(*pattern), |
| 6242 static_cast<i::JSRegExp::Flags>(flags)), | 6269 static_cast<i::JSRegExp::Flags>(flags)), |
| 6243 &result); | 6270 &result); |
| 6244 RETURN_ON_FAILED_EXECUTION(RegExp); | 6271 RETURN_ON_FAILED_EXECUTION(RegExp); |
| 6245 RETURN_ESCAPED(result); | 6272 RETURN_ESCAPED(result); |
| 6246 } | 6273 } |
| 6247 | 6274 |
| 6248 | 6275 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 6273 #undef REGEXP_FLAG_ASSERT_EQ | 6300 #undef REGEXP_FLAG_ASSERT_EQ |
| 6274 | 6301 |
| 6275 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 6302 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
| 6276 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6303 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
| 6277 return RegExp::Flags(static_cast<int>(obj->GetFlags())); | 6304 return RegExp::Flags(static_cast<int>(obj->GetFlags())); |
| 6278 } | 6305 } |
| 6279 | 6306 |
| 6280 | 6307 |
| 6281 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { | 6308 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { |
| 6282 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6309 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6283 LOG_API(i_isolate, "Array::New"); | 6310 LOG_API(i_isolate, Array_New, "Array::New"); |
| 6284 ENTER_V8(i_isolate); | 6311 ENTER_V8(i_isolate); |
| 6285 int real_length = length > 0 ? length : 0; | 6312 int real_length = length > 0 ? length : 0; |
| 6286 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); | 6313 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
| 6287 i::Handle<i::Object> length_obj = | 6314 i::Handle<i::Object> length_obj = |
| 6288 i_isolate->factory()->NewNumberFromInt(real_length); | 6315 i_isolate->factory()->NewNumberFromInt(real_length); |
| 6289 obj->set_length(*length_obj); | 6316 obj->set_length(*length_obj); |
| 6290 return Utils::ToLocal(obj); | 6317 return Utils::ToLocal(obj); |
| 6291 } | 6318 } |
| 6292 | 6319 |
| 6293 | 6320 |
| 6294 uint32_t v8::Array::Length() const { | 6321 uint32_t v8::Array::Length() const { |
| 6295 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 6322 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
| 6296 i::Object* length = obj->length(); | 6323 i::Object* length = obj->length(); |
| 6297 if (length->IsSmi()) { | 6324 if (length->IsSmi()) { |
| 6298 return i::Smi::cast(length)->value(); | 6325 return i::Smi::cast(length)->value(); |
| 6299 } else { | 6326 } else { |
| 6300 return static_cast<uint32_t>(length->Number()); | 6327 return static_cast<uint32_t>(length->Number()); |
| 6301 } | 6328 } |
| 6302 } | 6329 } |
| 6303 | 6330 |
| 6304 | 6331 |
| 6305 MaybeLocal<Object> Array::CloneElementAt(Local<Context> context, | 6332 MaybeLocal<Object> Array::CloneElementAt(Local<Context> context, |
| 6306 uint32_t index) { | 6333 uint32_t index) { |
| 6307 PREPARE_FOR_EXECUTION(context, "v8::Array::CloneElementAt()", Object); | 6334 PREPARE_FOR_EXECUTION(context, v8_Array_CloneElementAt, |
| 6335 "v8::Array::CloneElementAt", Object); | |
| 6308 auto self = Utils::OpenHandle(this); | 6336 auto self = Utils::OpenHandle(this); |
| 6309 if (!self->HasFastObjectElements()) return Local<Object>(); | 6337 if (!self->HasFastObjectElements()) return Local<Object>(); |
| 6310 i::FixedArray* elms = i::FixedArray::cast(self->elements()); | 6338 i::FixedArray* elms = i::FixedArray::cast(self->elements()); |
| 6311 i::Object* paragon = elms->get(index); | 6339 i::Object* paragon = elms->get(index); |
| 6312 if (!paragon->IsJSObject()) return Local<Object>(); | 6340 if (!paragon->IsJSObject()) return Local<Object>(); |
| 6313 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); | 6341 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); |
| 6314 Local<Object> result; | 6342 Local<Object> result; |
| 6315 has_pending_exception = | 6343 has_pending_exception = |
| 6316 !ToLocal<Object>(isolate->factory()->CopyJSObject(paragon_handle), | 6344 !ToLocal<Object>(isolate->factory()->CopyJSObject(paragon_handle), |
| 6317 &result); | 6345 &result); |
| 6318 RETURN_ON_FAILED_EXECUTION(Object); | 6346 RETURN_ON_FAILED_EXECUTION(Object); |
| 6319 RETURN_ESCAPED(result); | 6347 RETURN_ESCAPED(result); |
| 6320 } | 6348 } |
| 6321 | 6349 |
| 6322 | 6350 |
| 6323 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); } | 6351 Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); } |
| 6324 | 6352 |
| 6325 | 6353 |
| 6326 Local<v8::Map> v8::Map::New(Isolate* isolate) { | 6354 Local<v8::Map> v8::Map::New(Isolate* isolate) { |
| 6327 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6355 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6328 LOG_API(i_isolate, "Map::New"); | 6356 LOG_API(i_isolate, Map_New, "Map::New"); |
| 6329 ENTER_V8(i_isolate); | 6357 ENTER_V8(i_isolate); |
| 6330 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap(); | 6358 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap(); |
| 6331 return Utils::ToLocal(obj); | 6359 return Utils::ToLocal(obj); |
| 6332 } | 6360 } |
| 6333 | 6361 |
| 6334 | 6362 |
| 6335 size_t v8::Map::Size() const { | 6363 size_t v8::Map::Size() const { |
| 6336 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); | 6364 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); |
| 6337 return i::OrderedHashMap::cast(obj->table())->NumberOfElements(); | 6365 return i::OrderedHashMap::cast(obj->table())->NumberOfElements(); |
| 6338 } | 6366 } |
| 6339 | 6367 |
| 6340 | 6368 |
| 6341 void Map::Clear() { | 6369 void Map::Clear() { |
| 6342 auto self = Utils::OpenHandle(this); | 6370 auto self = Utils::OpenHandle(this); |
| 6343 i::Isolate* isolate = self->GetIsolate(); | 6371 i::Isolate* isolate = self->GetIsolate(); |
| 6344 LOG_API(isolate, "Map::Clear"); | 6372 LOG_API(isolate, Map_Clear, "Map::Clear"); |
| 6345 ENTER_V8(isolate); | 6373 ENTER_V8(isolate); |
| 6346 i::JSMap::Clear(self); | 6374 i::JSMap::Clear(self); |
| 6347 } | 6375 } |
| 6348 | 6376 |
| 6349 | 6377 |
| 6350 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) { | 6378 MaybeLocal<Value> Map::Get(Local<Context> context, Local<Value> key) { |
| 6351 PREPARE_FOR_EXECUTION(context, "Map::Get", Value); | 6379 PREPARE_FOR_EXECUTION(context, Map_Get, "Map::Get", Value); |
| 6352 auto self = Utils::OpenHandle(this); | 6380 auto self = Utils::OpenHandle(this); |
| 6353 Local<Value> result; | 6381 Local<Value> result; |
| 6354 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6382 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6355 has_pending_exception = | 6383 has_pending_exception = |
| 6356 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self, | 6384 !ToLocal<Value>(i::Execution::Call(isolate, isolate->map_get(), self, |
| 6357 arraysize(argv), argv), | 6385 arraysize(argv), argv), |
| 6358 &result); | 6386 &result); |
| 6359 RETURN_ON_FAILED_EXECUTION(Value); | 6387 RETURN_ON_FAILED_EXECUTION(Value); |
| 6360 RETURN_ESCAPED(result); | 6388 RETURN_ESCAPED(result); |
| 6361 } | 6389 } |
| 6362 | 6390 |
| 6363 | 6391 |
| 6364 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key, | 6392 MaybeLocal<Map> Map::Set(Local<Context> context, Local<Value> key, |
| 6365 Local<Value> value) { | 6393 Local<Value> value) { |
| 6366 PREPARE_FOR_EXECUTION(context, "Map::Set", Map); | 6394 PREPARE_FOR_EXECUTION(context, Map_Set, "Map::Set", Map); |
| 6367 auto self = Utils::OpenHandle(this); | 6395 auto self = Utils::OpenHandle(this); |
| 6368 i::Handle<i::Object> result; | 6396 i::Handle<i::Object> result; |
| 6369 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), | 6397 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key), |
| 6370 Utils::OpenHandle(*value)}; | 6398 Utils::OpenHandle(*value)}; |
| 6371 has_pending_exception = !i::Execution::Call(isolate, isolate->map_set(), self, | 6399 has_pending_exception = !i::Execution::Call(isolate, isolate->map_set(), self, |
| 6372 arraysize(argv), argv) | 6400 arraysize(argv), argv) |
| 6373 .ToHandle(&result); | 6401 .ToHandle(&result); |
| 6374 RETURN_ON_FAILED_EXECUTION(Map); | 6402 RETURN_ON_FAILED_EXECUTION(Map); |
| 6375 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); | 6403 RETURN_ESCAPED(Local<Map>::Cast(Utils::ToLocal(result))); |
| 6376 } | 6404 } |
| 6377 | 6405 |
| 6378 | 6406 |
| 6379 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) { | 6407 Maybe<bool> Map::Has(Local<Context> context, Local<Value> key) { |
| 6380 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Has", bool); | 6408 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map_Has, "Map::Has", bool); |
| 6381 auto self = Utils::OpenHandle(this); | 6409 auto self = Utils::OpenHandle(this); |
| 6382 i::Handle<i::Object> result; | 6410 i::Handle<i::Object> result; |
| 6383 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6411 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6384 has_pending_exception = !i::Execution::Call(isolate, isolate->map_has(), self, | 6412 has_pending_exception = !i::Execution::Call(isolate, isolate->map_has(), self, |
| 6385 arraysize(argv), argv) | 6413 arraysize(argv), argv) |
| 6386 .ToHandle(&result); | 6414 .ToHandle(&result); |
| 6387 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6415 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6388 return Just(result->IsTrue()); | 6416 return Just(result->IsTrue()); |
| 6389 } | 6417 } |
| 6390 | 6418 |
| 6391 | 6419 |
| 6392 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) { | 6420 Maybe<bool> Map::Delete(Local<Context> context, Local<Value> key) { |
| 6393 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Map::Delete", bool); | 6421 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Map_Delete, "Map::Delete", bool); |
| 6394 auto self = Utils::OpenHandle(this); | 6422 auto self = Utils::OpenHandle(this); |
| 6395 i::Handle<i::Object> result; | 6423 i::Handle<i::Object> result; |
| 6396 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6424 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6397 has_pending_exception = !i::Execution::Call(isolate, isolate->map_delete(), | 6425 has_pending_exception = !i::Execution::Call(isolate, isolate->map_delete(), |
| 6398 self, arraysize(argv), argv) | 6426 self, arraysize(argv), argv) |
| 6399 .ToHandle(&result); | 6427 .ToHandle(&result); |
| 6400 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6428 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6401 return Just(result->IsTrue()); | 6429 return Just(result->IsTrue()); |
| 6402 } | 6430 } |
| 6403 | 6431 |
| 6404 | 6432 |
| 6405 Local<Array> Map::AsArray() const { | 6433 Local<Array> Map::AsArray() const { |
| 6406 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); | 6434 i::Handle<i::JSMap> obj = Utils::OpenHandle(this); |
| 6407 i::Isolate* isolate = obj->GetIsolate(); | 6435 i::Isolate* isolate = obj->GetIsolate(); |
| 6408 i::Factory* factory = isolate->factory(); | 6436 i::Factory* factory = isolate->factory(); |
| 6409 LOG_API(isolate, "Map::AsArray"); | 6437 LOG_API(isolate, Map_AsArray, "Map::AsArray"); |
| 6410 ENTER_V8(isolate); | 6438 ENTER_V8(isolate); |
| 6411 i::Handle<i::OrderedHashMap> table(i::OrderedHashMap::cast(obj->table())); | 6439 i::Handle<i::OrderedHashMap> table(i::OrderedHashMap::cast(obj->table())); |
| 6412 int size = table->NumberOfElements(); | 6440 int size = table->NumberOfElements(); |
| 6413 int length = size * 2; | 6441 int length = size * 2; |
| 6414 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); | 6442 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); |
| 6415 for (int i = 0; i < size; ++i) { | 6443 for (int i = 0; i < size; ++i) { |
| 6416 if (table->KeyAt(i)->IsTheHole()) continue; | 6444 if (table->KeyAt(i)->IsTheHole()) continue; |
| 6417 result->set(i * 2, table->KeyAt(i)); | 6445 result->set(i * 2, table->KeyAt(i)); |
| 6418 result->set(i * 2 + 1, table->ValueAt(i)); | 6446 result->set(i * 2 + 1, table->ValueAt(i)); |
| 6419 } | 6447 } |
| 6420 i::Handle<i::JSArray> result_array = | 6448 i::Handle<i::JSArray> result_array = |
| 6421 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6449 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
| 6422 return Utils::ToLocal(result_array); | 6450 return Utils::ToLocal(result_array); |
| 6423 } | 6451 } |
| 6424 | 6452 |
| 6425 | 6453 |
| 6426 Local<v8::Set> v8::Set::New(Isolate* isolate) { | 6454 Local<v8::Set> v8::Set::New(Isolate* isolate) { |
| 6427 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6455 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6428 LOG_API(i_isolate, "Set::New"); | 6456 LOG_API(i_isolate, Set_New, "Set::New"); |
| 6429 ENTER_V8(i_isolate); | 6457 ENTER_V8(i_isolate); |
| 6430 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); | 6458 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet(); |
| 6431 return Utils::ToLocal(obj); | 6459 return Utils::ToLocal(obj); |
| 6432 } | 6460 } |
| 6433 | 6461 |
| 6434 | 6462 |
| 6435 size_t v8::Set::Size() const { | 6463 size_t v8::Set::Size() const { |
| 6436 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); | 6464 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); |
| 6437 return i::OrderedHashSet::cast(obj->table())->NumberOfElements(); | 6465 return i::OrderedHashSet::cast(obj->table())->NumberOfElements(); |
| 6438 } | 6466 } |
| 6439 | 6467 |
| 6440 | 6468 |
| 6441 void Set::Clear() { | 6469 void Set::Clear() { |
| 6442 auto self = Utils::OpenHandle(this); | 6470 auto self = Utils::OpenHandle(this); |
| 6443 i::Isolate* isolate = self->GetIsolate(); | 6471 i::Isolate* isolate = self->GetIsolate(); |
| 6444 LOG_API(isolate, "Set::Clear"); | 6472 LOG_API(isolate, Set_Clear, "Set::Clear"); |
| 6445 ENTER_V8(isolate); | 6473 ENTER_V8(isolate); |
| 6446 i::JSSet::Clear(self); | 6474 i::JSSet::Clear(self); |
| 6447 } | 6475 } |
| 6448 | 6476 |
| 6449 | 6477 |
| 6450 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) { | 6478 MaybeLocal<Set> Set::Add(Local<Context> context, Local<Value> key) { |
| 6451 PREPARE_FOR_EXECUTION(context, "Set::Add", Set); | 6479 PREPARE_FOR_EXECUTION(context, Set_Add, "Set::Add", Set); |
| 6452 auto self = Utils::OpenHandle(this); | 6480 auto self = Utils::OpenHandle(this); |
| 6453 i::Handle<i::Object> result; | 6481 i::Handle<i::Object> result; |
| 6454 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6482 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6455 has_pending_exception = !i::Execution::Call(isolate, isolate->set_add(), self, | 6483 has_pending_exception = !i::Execution::Call(isolate, isolate->set_add(), self, |
| 6456 arraysize(argv), argv) | 6484 arraysize(argv), argv) |
| 6457 .ToHandle(&result); | 6485 .ToHandle(&result); |
| 6458 RETURN_ON_FAILED_EXECUTION(Set); | 6486 RETURN_ON_FAILED_EXECUTION(Set); |
| 6459 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); | 6487 RETURN_ESCAPED(Local<Set>::Cast(Utils::ToLocal(result))); |
| 6460 } | 6488 } |
| 6461 | 6489 |
| 6462 | 6490 |
| 6463 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) { | 6491 Maybe<bool> Set::Has(Local<Context> context, Local<Value> key) { |
| 6464 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Has", bool); | 6492 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set_Has, "Set::Has", bool); |
| 6465 auto self = Utils::OpenHandle(this); | 6493 auto self = Utils::OpenHandle(this); |
| 6466 i::Handle<i::Object> result; | 6494 i::Handle<i::Object> result; |
| 6467 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6495 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6468 has_pending_exception = !i::Execution::Call(isolate, isolate->set_has(), self, | 6496 has_pending_exception = !i::Execution::Call(isolate, isolate->set_has(), self, |
| 6469 arraysize(argv), argv) | 6497 arraysize(argv), argv) |
| 6470 .ToHandle(&result); | 6498 .ToHandle(&result); |
| 6471 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6499 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6472 return Just(result->IsTrue()); | 6500 return Just(result->IsTrue()); |
| 6473 } | 6501 } |
| 6474 | 6502 |
| 6475 | 6503 |
| 6476 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) { | 6504 Maybe<bool> Set::Delete(Local<Context> context, Local<Value> key) { |
| 6477 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Set::Delete", bool); | 6505 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Set_Delete, "Set::Delete", bool); |
| 6478 auto self = Utils::OpenHandle(this); | 6506 auto self = Utils::OpenHandle(this); |
| 6479 i::Handle<i::Object> result; | 6507 i::Handle<i::Object> result; |
| 6480 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; | 6508 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)}; |
| 6481 has_pending_exception = !i::Execution::Call(isolate, isolate->set_delete(), | 6509 has_pending_exception = !i::Execution::Call(isolate, isolate->set_delete(), |
| 6482 self, arraysize(argv), argv) | 6510 self, arraysize(argv), argv) |
| 6483 .ToHandle(&result); | 6511 .ToHandle(&result); |
| 6484 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6512 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6485 return Just(result->IsTrue()); | 6513 return Just(result->IsTrue()); |
| 6486 } | 6514 } |
| 6487 | 6515 |
| 6488 | 6516 |
| 6489 Local<Array> Set::AsArray() const { | 6517 Local<Array> Set::AsArray() const { |
| 6490 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); | 6518 i::Handle<i::JSSet> obj = Utils::OpenHandle(this); |
| 6491 i::Isolate* isolate = obj->GetIsolate(); | 6519 i::Isolate* isolate = obj->GetIsolate(); |
| 6492 i::Factory* factory = isolate->factory(); | 6520 i::Factory* factory = isolate->factory(); |
| 6493 LOG_API(isolate, "Set::AsArray"); | 6521 LOG_API(isolate, Set_AsArray, "Set::AsArray"); |
| 6494 ENTER_V8(isolate); | 6522 ENTER_V8(isolate); |
| 6495 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); | 6523 i::Handle<i::OrderedHashSet> table(i::OrderedHashSet::cast(obj->table())); |
| 6496 int length = table->NumberOfElements(); | 6524 int length = table->NumberOfElements(); |
| 6497 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); | 6525 i::Handle<i::FixedArray> result = factory->NewFixedArray(length); |
| 6498 for (int i = 0; i < length; ++i) { | 6526 for (int i = 0; i < length; ++i) { |
| 6499 i::Object* key = table->KeyAt(i); | 6527 i::Object* key = table->KeyAt(i); |
| 6500 if (!key->IsTheHole()) { | 6528 if (!key->IsTheHole()) { |
| 6501 result->set(i, key); | 6529 result->set(i, key); |
| 6502 } | 6530 } |
| 6503 } | 6531 } |
| 6504 i::Handle<i::JSArray> result_array = | 6532 i::Handle<i::JSArray> result_array = |
| 6505 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); | 6533 factory->NewJSArrayWithElements(result, i::FAST_ELEMENTS, length); |
| 6506 return Utils::ToLocal(result_array); | 6534 return Utils::ToLocal(result_array); |
| 6507 } | 6535 } |
| 6508 | 6536 |
| 6509 | 6537 |
| 6510 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { | 6538 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { |
| 6511 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); | 6539 PREPARE_FOR_EXECUTION(context, Promise_Resolver_New, "Promise::Resolver::New", |
| 6540 Resolver); | |
| 6512 i::Handle<i::Object> result; | 6541 i::Handle<i::Object> result; |
| 6513 has_pending_exception = | 6542 has_pending_exception = |
| 6514 !i::Execution::Call(isolate, isolate->promise_create(), | 6543 !i::Execution::Call(isolate, isolate->promise_create(), |
| 6515 isolate->factory()->undefined_value(), 0, NULL) | 6544 isolate->factory()->undefined_value(), 0, NULL) |
| 6516 .ToHandle(&result); | 6545 .ToHandle(&result); |
| 6517 RETURN_ON_FAILED_EXECUTION(Promise::Resolver); | 6546 RETURN_ON_FAILED_EXECUTION(Promise::Resolver); |
| 6518 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result))); | 6547 RETURN_ESCAPED(Local<Promise::Resolver>::Cast(Utils::ToLocal(result))); |
| 6519 } | 6548 } |
| 6520 | 6549 |
| 6521 | 6550 |
| 6522 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { | 6551 Local<Promise::Resolver> Promise::Resolver::New(Isolate* isolate) { |
| 6523 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), | 6552 RETURN_TO_LOCAL_UNCHECKED(New(isolate->GetCurrentContext()), |
| 6524 Promise::Resolver); | 6553 Promise::Resolver); |
| 6525 } | 6554 } |
| 6526 | 6555 |
| 6527 | 6556 |
| 6528 Local<Promise> Promise::Resolver::GetPromise() { | 6557 Local<Promise> Promise::Resolver::GetPromise() { |
| 6529 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); | 6558 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
| 6530 return Local<Promise>::Cast(Utils::ToLocal(promise)); | 6559 return Local<Promise>::Cast(Utils::ToLocal(promise)); |
| 6531 } | 6560 } |
| 6532 | 6561 |
| 6533 | 6562 |
| 6534 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, | 6563 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, |
| 6535 Local<Value> value) { | 6564 Local<Value> value) { |
| 6536 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6565 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver_Resolve, |
| 6566 "Promise::Resolver::Resolve", bool); | |
| 6537 auto self = Utils::OpenHandle(this); | 6567 auto self = Utils::OpenHandle(this); |
| 6538 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6568 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
| 6539 has_pending_exception = | 6569 has_pending_exception = |
| 6540 i::Execution::Call(isolate, isolate->promise_resolve(), | 6570 i::Execution::Call(isolate, isolate->promise_resolve(), |
| 6541 isolate->factory()->undefined_value(), arraysize(argv), | 6571 isolate->factory()->undefined_value(), arraysize(argv), |
| 6542 argv) | 6572 argv) |
| 6543 .is_null(); | 6573 .is_null(); |
| 6544 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6574 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6545 return Just(true); | 6575 return Just(true); |
| 6546 } | 6576 } |
| 6547 | 6577 |
| 6548 | 6578 |
| 6549 void Promise::Resolver::Resolve(Local<Value> value) { | 6579 void Promise::Resolver::Resolve(Local<Value> value) { |
| 6550 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6580 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6551 USE(Resolve(context, value)); | 6581 USE(Resolve(context, value)); |
| 6552 } | 6582 } |
| 6553 | 6583 |
| 6554 | 6584 |
| 6555 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, | 6585 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, |
| 6556 Local<Value> value) { | 6586 Local<Value> value) { |
| 6557 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6587 PREPARE_FOR_EXECUTION_PRIMITIVE(context, Promise_Resolver_Resolve, |
| 6588 "Promise::Resolver::Resolve", bool); | |
| 6558 auto self = Utils::OpenHandle(this); | 6589 auto self = Utils::OpenHandle(this); |
| 6559 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6590 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
| 6560 has_pending_exception = | 6591 has_pending_exception = |
| 6561 i::Execution::Call(isolate, isolate->promise_reject(), | 6592 i::Execution::Call(isolate, isolate->promise_reject(), |
| 6562 isolate->factory()->undefined_value(), arraysize(argv), | 6593 isolate->factory()->undefined_value(), arraysize(argv), |
| 6563 argv) | 6594 argv) |
| 6564 .is_null(); | 6595 .is_null(); |
| 6565 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6596 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 6566 return Just(true); | 6597 return Just(true); |
| 6567 } | 6598 } |
| 6568 | 6599 |
| 6569 | 6600 |
| 6570 void Promise::Resolver::Reject(Local<Value> value) { | 6601 void Promise::Resolver::Reject(Local<Value> value) { |
| 6571 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6602 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6572 USE(Reject(context, value)); | 6603 USE(Reject(context, value)); |
| 6573 } | 6604 } |
| 6574 | 6605 |
| 6575 | 6606 |
| 6576 namespace { | 6607 namespace { |
| 6577 | 6608 |
| 6578 MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, | 6609 MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, |
| 6579 Local<Function> handler) { | 6610 Local<Function> handler) { |
| 6580 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); | 6611 PREPARE_FOR_EXECUTION(context, Promise_Chain, "Promise::Chain", Promise); |
| 6581 auto self = Utils::OpenHandle(value); | 6612 auto self = Utils::OpenHandle(value); |
| 6582 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; | 6613 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; |
| 6583 i::Handle<i::Object> result; | 6614 i::Handle<i::Object> result; |
| 6584 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), | 6615 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), |
| 6585 self, arraysize(argv), argv) | 6616 self, arraysize(argv), argv) |
| 6586 .ToHandle(&result); | 6617 .ToHandle(&result); |
| 6587 RETURN_ON_FAILED_EXECUTION(Promise); | 6618 RETURN_ON_FAILED_EXECUTION(Promise); |
| 6588 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6619 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
| 6589 } | 6620 } |
| 6590 | 6621 |
| 6591 } // namespace | 6622 } // namespace |
| 6592 | 6623 |
| 6593 | 6624 |
| 6594 MaybeLocal<Promise> Promise::Chain(Local<Context> context, | 6625 MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
| 6595 Local<Function> handler) { | 6626 Local<Function> handler) { |
| 6596 return DoChain(this, context, handler); | 6627 return DoChain(this, context, handler); |
| 6597 } | 6628 } |
| 6598 | 6629 |
| 6599 | 6630 |
| 6600 Local<Promise> Promise::Chain(Local<Function> handler) { | 6631 Local<Promise> Promise::Chain(Local<Function> handler) { |
| 6601 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6632 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6602 RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); | 6633 RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); |
| 6603 } | 6634 } |
| 6604 | 6635 |
| 6605 | 6636 |
| 6606 MaybeLocal<Promise> Promise::Catch(Local<Context> context, | 6637 MaybeLocal<Promise> Promise::Catch(Local<Context> context, |
| 6607 Local<Function> handler) { | 6638 Local<Function> handler) { |
| 6608 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise); | 6639 PREPARE_FOR_EXECUTION(context, Promise_Catch, "Promise::Catch", Promise); |
| 6609 auto self = Utils::OpenHandle(this); | 6640 auto self = Utils::OpenHandle(this); |
| 6610 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6641 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
| 6611 i::Handle<i::Object> result; | 6642 i::Handle<i::Object> result; |
| 6612 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), | 6643 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), |
| 6613 self, arraysize(argv), argv) | 6644 self, arraysize(argv), argv) |
| 6614 .ToHandle(&result); | 6645 .ToHandle(&result); |
| 6615 RETURN_ON_FAILED_EXECUTION(Promise); | 6646 RETURN_ON_FAILED_EXECUTION(Promise); |
| 6616 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6647 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
| 6617 } | 6648 } |
| 6618 | 6649 |
| 6619 | 6650 |
| 6620 Local<Promise> Promise::Catch(Local<Function> handler) { | 6651 Local<Promise> Promise::Catch(Local<Function> handler) { |
| 6621 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6652 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6622 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); | 6653 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); |
| 6623 } | 6654 } |
| 6624 | 6655 |
| 6625 | 6656 |
| 6626 MaybeLocal<Promise> Promise::Then(Local<Context> context, | 6657 MaybeLocal<Promise> Promise::Then(Local<Context> context, |
| 6627 Local<Function> handler) { | 6658 Local<Function> handler) { |
| 6628 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise); | 6659 PREPARE_FOR_EXECUTION(context, Promise_Then, "Promise::Then", Promise); |
| 6629 auto self = Utils::OpenHandle(this); | 6660 auto self = Utils::OpenHandle(this); |
| 6630 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6661 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
| 6631 i::Handle<i::Object> result; | 6662 i::Handle<i::Object> result; |
| 6632 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_then(), | 6663 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_then(), |
| 6633 self, arraysize(argv), argv) | 6664 self, arraysize(argv), argv) |
| 6634 .ToHandle(&result); | 6665 .ToHandle(&result); |
| 6635 RETURN_ON_FAILED_EXECUTION(Promise); | 6666 RETURN_ON_FAILED_EXECUTION(Promise); |
| 6636 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6667 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
| 6637 } | 6668 } |
| 6638 | 6669 |
| 6639 | 6670 |
| 6640 Local<Promise> Promise::Then(Local<Function> handler) { | 6671 Local<Promise> Promise::Then(Local<Function> handler) { |
| 6641 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6672 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 6642 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); | 6673 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); |
| 6643 } | 6674 } |
| 6644 | 6675 |
| 6645 | 6676 |
| 6646 bool Promise::HasHandler() { | 6677 bool Promise::HasHandler() { |
| 6647 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); | 6678 i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this); |
| 6648 i::Isolate* isolate = promise->GetIsolate(); | 6679 i::Isolate* isolate = promise->GetIsolate(); |
| 6649 LOG_API(isolate, "Promise::HasRejectHandler"); | 6680 LOG_API(isolate, Promise_HasRejectHandler, "Promise::HasRejectHandler"); |
| 6650 ENTER_V8(isolate); | 6681 ENTER_V8(isolate); |
| 6651 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); | 6682 i::Handle<i::Symbol> key = isolate->factory()->promise_has_handler_symbol(); |
| 6652 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); | 6683 return i::JSReceiver::GetDataProperty(promise, key)->IsTrue(); |
| 6653 } | 6684 } |
| 6654 | 6685 |
| 6655 | 6686 |
| 6656 Local<Object> Proxy::GetTarget() { | 6687 Local<Object> Proxy::GetTarget() { |
| 6657 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); | 6688 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); |
| 6658 i::Handle<i::JSReceiver> target(self->target()); | 6689 i::Handle<i::JSReceiver> target(self->target()); |
| 6659 return Utils::ToLocal(target); | 6690 return Utils::ToLocal(target); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 6674 | 6705 |
| 6675 | 6706 |
| 6676 void Proxy::Revoke() { | 6707 void Proxy::Revoke() { |
| 6677 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); | 6708 i::Handle<i::JSProxy> self = Utils::OpenHandle(this); |
| 6678 i::JSProxy::Revoke(self); | 6709 i::JSProxy::Revoke(self); |
| 6679 } | 6710 } |
| 6680 | 6711 |
| 6681 | 6712 |
| 6682 MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target, | 6713 MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target, |
| 6683 Local<Object> local_handler) { | 6714 Local<Object> local_handler) { |
| 6684 PREPARE_FOR_EXECUTION(context, "Proxy::New", Proxy); | 6715 PREPARE_FOR_EXECUTION(context, Proxy_New, "Proxy::New", Proxy); |
| 6685 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); | 6716 i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target); |
| 6686 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); | 6717 i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler); |
| 6687 Local<Proxy> result; | 6718 Local<Proxy> result; |
| 6688 has_pending_exception = | 6719 has_pending_exception = |
| 6689 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); | 6720 !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result); |
| 6690 RETURN_ON_FAILED_EXECUTION(Proxy); | 6721 RETURN_ON_FAILED_EXECUTION(Proxy); |
| 6691 RETURN_ESCAPED(result); | 6722 RETURN_ESCAPED(result); |
| 6692 } | 6723 } |
| 6693 | 6724 |
| 6694 bool v8::ArrayBuffer::IsExternal() const { | 6725 bool v8::ArrayBuffer::IsExternal() const { |
| 6695 return Utils::OpenHandle(this)->is_external(); | 6726 return Utils::OpenHandle(this)->is_external(); |
| 6696 } | 6727 } |
| 6697 | 6728 |
| 6698 | 6729 |
| 6699 bool v8::ArrayBuffer::IsNeuterable() const { | 6730 bool v8::ArrayBuffer::IsNeuterable() const { |
| 6700 return Utils::OpenHandle(this)->is_neuterable(); | 6731 return Utils::OpenHandle(this)->is_neuterable(); |
| 6701 } | 6732 } |
| 6702 | 6733 |
| 6703 | 6734 |
| 6704 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6735 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
| 6705 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6736 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
| 6706 i::Isolate* isolate = self->GetIsolate(); | 6737 i::Isolate* isolate = self->GetIsolate(); |
| 6707 Utils::ApiCheck(!self->is_external(), "v8::ArrayBuffer::Externalize", | 6738 Utils::ApiCheck(!self->is_external(), "v8_ArrayBuffer_Externalize", |
| 6708 "ArrayBuffer already externalized"); | 6739 "ArrayBuffer already externalized"); |
| 6709 self->set_is_external(true); | 6740 self->set_is_external(true); |
| 6710 isolate->heap()->UnregisterArrayBuffer(*self); | 6741 isolate->heap()->UnregisterArrayBuffer(*self); |
| 6711 | 6742 |
| 6712 return GetContents(); | 6743 return GetContents(); |
| 6713 } | 6744 } |
| 6714 | 6745 |
| 6715 | 6746 |
| 6716 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { | 6747 v8::ArrayBuffer::Contents v8::ArrayBuffer::GetContents() { |
| 6717 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6748 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
| 6718 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6749 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
| 6719 Contents contents; | 6750 Contents contents; |
| 6720 contents.data_ = self->backing_store(); | 6751 contents.data_ = self->backing_store(); |
| 6721 contents.byte_length_ = byte_length; | 6752 contents.byte_length_ = byte_length; |
| 6722 return contents; | 6753 return contents; |
| 6723 } | 6754 } |
| 6724 | 6755 |
| 6725 | 6756 |
| 6726 void v8::ArrayBuffer::Neuter() { | 6757 void v8::ArrayBuffer::Neuter() { |
| 6727 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6758 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6728 i::Isolate* isolate = obj->GetIsolate(); | 6759 i::Isolate* isolate = obj->GetIsolate(); |
| 6729 Utils::ApiCheck(obj->is_external(), | 6760 Utils::ApiCheck(obj->is_external(), |
| 6730 "v8::ArrayBuffer::Neuter", | 6761 "v8::ArrayBuffer::Neuter", |
| 6731 "Only externalized ArrayBuffers can be neutered"); | 6762 "Only externalized ArrayBuffers can be neutered"); |
| 6732 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter", | 6763 Utils::ApiCheck(obj->is_neuterable(), "v8::ArrayBuffer::Neuter", |
| 6733 "Only neuterable ArrayBuffers can be neutered"); | 6764 "Only neuterable ArrayBuffers can be neutered"); |
| 6734 LOG_API(obj->GetIsolate(), "v8::ArrayBuffer::Neuter()"); | 6765 LOG_API(obj->GetIsolate(), v8_ArrayBuffer_Neuter, "v8::ArrayBuffer::Neuter"); |
| 6735 ENTER_V8(isolate); | 6766 ENTER_V8(isolate); |
| 6736 obj->Neuter(); | 6767 obj->Neuter(); |
| 6737 } | 6768 } |
| 6738 | 6769 |
| 6739 | 6770 |
| 6740 size_t v8::ArrayBuffer::ByteLength() const { | 6771 size_t v8::ArrayBuffer::ByteLength() const { |
| 6741 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6772 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6742 return static_cast<size_t>(obj->byte_length()->Number()); | 6773 return static_cast<size_t>(obj->byte_length()->Number()); |
| 6743 } | 6774 } |
| 6744 | 6775 |
| 6745 | 6776 |
| 6746 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { | 6777 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
| 6747 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6778 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6748 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); | 6779 LOG_API(i_isolate, v8_ArrayBuffer_New, "v8::ArrayBuffer::New"); |
| 6749 ENTER_V8(i_isolate); | 6780 ENTER_V8(i_isolate); |
| 6750 i::Handle<i::JSArrayBuffer> obj = | 6781 i::Handle<i::JSArrayBuffer> obj = |
| 6751 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6782 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
| 6752 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); | 6783 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length); |
| 6753 return Utils::ToLocal(obj); | 6784 return Utils::ToLocal(obj); |
| 6754 } | 6785 } |
| 6755 | 6786 |
| 6756 | 6787 |
| 6757 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, | 6788 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 6758 size_t byte_length, | 6789 size_t byte_length, |
| 6759 ArrayBufferCreationMode mode) { | 6790 ArrayBufferCreationMode mode) { |
| 6760 // Embedders must guarantee that the external backing store is valid. | 6791 // Embedders must guarantee that the external backing store is valid. |
| 6761 CHECK(byte_length == 0 || data != NULL); | 6792 CHECK(byte_length == 0 || data != NULL); |
| 6762 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6793 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6763 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 6794 LOG_API(i_isolate, v8_ArrayBuffer_New, "v8::ArrayBuffer::New"); |
| 6764 ENTER_V8(i_isolate); | 6795 ENTER_V8(i_isolate); |
| 6765 i::Handle<i::JSArrayBuffer> obj = | 6796 i::Handle<i::JSArrayBuffer> obj = |
| 6766 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); | 6797 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kNotShared); |
| 6767 i::JSArrayBuffer::Setup(obj, i_isolate, | 6798 i::JSArrayBuffer::Setup(obj, i_isolate, |
| 6768 mode == ArrayBufferCreationMode::kExternalized, data, | 6799 mode == ArrayBufferCreationMode::kExternalized, data, |
| 6769 byte_length); | 6800 byte_length); |
| 6770 return Utils::ToLocal(obj); | 6801 return Utils::ToLocal(obj); |
| 6771 } | 6802 } |
| 6772 | 6803 |
| 6773 | 6804 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6826 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6857 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| 6827 return static_cast<size_t>(obj->byte_length()->Number()); | 6858 return static_cast<size_t>(obj->byte_length()->Number()); |
| 6828 } | 6859 } |
| 6829 | 6860 |
| 6830 | 6861 |
| 6831 size_t v8::TypedArray::Length() { | 6862 size_t v8::TypedArray::Length() { |
| 6832 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); | 6863 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); |
| 6833 return static_cast<size_t>(obj->length_value()); | 6864 return static_cast<size_t>(obj->length_value()); |
| 6834 } | 6865 } |
| 6835 | 6866 |
| 6836 | 6867 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ |
| 6837 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ | 6868 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ |
| 6838 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ | 6869 size_t byte_offset, size_t length) { \ |
| 6839 size_t byte_offset, size_t length) { \ | 6870 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ |
| 6840 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ | 6871 LOG_API(isolate, v8_##Type##Array_New, \ |
| 6841 LOG_API(isolate, \ | 6872 "v8::" #Type "Array::New(Local<ArrayBuffer>, size_t, size_t)"); \ |
| 6842 "v8::" #Type "Array::New(Local<ArrayBuffer>, size_t, size_t)"); \ | 6873 ENTER_V8(isolate); \ |
| 6843 ENTER_V8(isolate); \ | 6874 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
| 6844 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6875 "v8::" #Type \ |
| 6845 "v8::" #Type \ | 6876 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ |
| 6846 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ | 6877 "length exceeds max allowed value")) { \ |
| 6847 "length exceeds max allowed value")) { \ | 6878 return Local<Type##Array>(); \ |
| 6848 return Local<Type##Array>(); \ | 6879 } \ |
| 6849 } \ | 6880 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ |
| 6850 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ | 6881 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
| 6851 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | 6882 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
| 6852 i::kExternal##Type##Array, buffer, byte_offset, length); \ | 6883 return Utils::ToLocal##Type##Array(obj); \ |
| 6853 return Utils::ToLocal##Type##Array(obj); \ | 6884 } \ |
| 6854 } \ | 6885 Local<Type##Array> Type##Array::New( \ |
| 6855 Local<Type##Array> Type##Array::New( \ | 6886 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ |
| 6856 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ | 6887 size_t length) { \ |
| 6857 size_t length) { \ | 6888 CHECK(i::FLAG_harmony_sharedarraybuffer); \ |
| 6858 CHECK(i::FLAG_harmony_sharedarraybuffer); \ | 6889 i::Isolate* isolate = \ |
| 6859 i::Isolate* isolate = \ | 6890 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ |
| 6860 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ | 6891 LOG_API(isolate, v8_##Type##Array_New, "v8::" #Type "Array::New"); \ |
| 6861 LOG_API(isolate, "v8::" #Type \ | 6892 ENTER_V8(isolate); \ |
| 6862 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)"); \ | 6893 if (!Utils::ApiCheck( \ |
| 6863 ENTER_V8(isolate); \ | 6894 length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
| 6864 if (!Utils::ApiCheck( \ | 6895 "v8::" #Type \ |
| 6865 length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6896 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ |
| 6866 "v8::" #Type \ | 6897 "length exceeds max allowed value")) { \ |
| 6867 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ | 6898 return Local<Type##Array>(); \ |
| 6868 "length exceeds max allowed value")) { \ | 6899 } \ |
| 6869 return Local<Type##Array>(); \ | 6900 i::Handle<i::JSArrayBuffer> buffer = \ |
| 6870 } \ | 6901 Utils::OpenHandle(*shared_array_buffer); \ |
| 6871 i::Handle<i::JSArrayBuffer> buffer = \ | 6902 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
| 6872 Utils::OpenHandle(*shared_array_buffer); \ | 6903 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
| 6873 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | 6904 return Utils::ToLocal##Type##Array(obj); \ |
| 6874 i::kExternal##Type##Array, buffer, byte_offset, length); \ | |
| 6875 return Utils::ToLocal##Type##Array(obj); \ | |
| 6876 } | 6905 } |
| 6877 | 6906 |
| 6878 | |
| 6879 TYPED_ARRAYS(TYPED_ARRAY_NEW) | 6907 TYPED_ARRAYS(TYPED_ARRAY_NEW) |
| 6880 #undef TYPED_ARRAY_NEW | 6908 #undef TYPED_ARRAY_NEW |
| 6881 | 6909 |
| 6882 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, | 6910 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, |
| 6883 size_t byte_offset, size_t byte_length) { | 6911 size_t byte_offset, size_t byte_length) { |
| 6884 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); | 6912 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); |
| 6885 i::Isolate* isolate = buffer->GetIsolate(); | 6913 i::Isolate* isolate = buffer->GetIsolate(); |
| 6886 LOG_API(isolate, "v8::DataView::New(Local<ArrayBuffer>, size_t, size_t)"); | 6914 LOG_API(isolate, v8_DataView_New, "v8::DataView::New"); |
| 6887 ENTER_V8(isolate); | 6915 ENTER_V8(isolate); |
| 6888 i::Handle<i::JSDataView> obj = | 6916 i::Handle<i::JSDataView> obj = |
| 6889 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6917 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
| 6890 return Utils::ToLocal(obj); | 6918 return Utils::ToLocal(obj); |
| 6891 } | 6919 } |
| 6892 | 6920 |
| 6893 | 6921 |
| 6894 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, | 6922 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, |
| 6895 size_t byte_offset, size_t byte_length) { | 6923 size_t byte_offset, size_t byte_length) { |
| 6896 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6924 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 6897 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); | 6925 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); |
| 6898 i::Isolate* isolate = buffer->GetIsolate(); | 6926 i::Isolate* isolate = buffer->GetIsolate(); |
| 6899 LOG_API(isolate, | 6927 LOG_API(isolate, v8_DataView_New, "v8::DataView::New"); |
| 6900 "v8::DataView::New(Local<SharedArrayBuffer>, size_t, size_t)"); | |
| 6901 ENTER_V8(isolate); | 6928 ENTER_V8(isolate); |
| 6902 i::Handle<i::JSDataView> obj = | 6929 i::Handle<i::JSDataView> obj = |
| 6903 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6930 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
| 6904 return Utils::ToLocal(obj); | 6931 return Utils::ToLocal(obj); |
| 6905 } | 6932 } |
| 6906 | 6933 |
| 6907 | 6934 |
| 6908 bool v8::SharedArrayBuffer::IsExternal() const { | 6935 bool v8::SharedArrayBuffer::IsExternal() const { |
| 6909 return Utils::OpenHandle(this)->is_external(); | 6936 return Utils::OpenHandle(this)->is_external(); |
| 6910 } | 6937 } |
| 6911 | 6938 |
| 6912 | 6939 |
| 6913 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { | 6940 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() { |
| 6914 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6941 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
| 6915 i::Isolate* isolate = self->GetIsolate(); | 6942 i::Isolate* isolate = self->GetIsolate(); |
| 6916 Utils::ApiCheck(!self->is_external(), "v8::SharedArrayBuffer::Externalize", | 6943 Utils::ApiCheck(!self->is_external(), "v8_SharedArrayBuffer_Externalize", |
| 6917 "SharedArrayBuffer already externalized"); | 6944 "SharedArrayBuffer already externalized"); |
| 6918 self->set_is_external(true); | 6945 self->set_is_external(true); |
| 6919 isolate->heap()->UnregisterArrayBuffer(*self); | 6946 isolate->heap()->UnregisterArrayBuffer(*self); |
| 6920 return GetContents(); | 6947 return GetContents(); |
| 6921 } | 6948 } |
| 6922 | 6949 |
| 6923 | 6950 |
| 6924 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { | 6951 v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() { |
| 6925 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); | 6952 i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this); |
| 6926 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); | 6953 size_t byte_length = static_cast<size_t>(self->byte_length()->Number()); |
| 6927 Contents contents; | 6954 Contents contents; |
| 6928 contents.data_ = self->backing_store(); | 6955 contents.data_ = self->backing_store(); |
| 6929 contents.byte_length_ = byte_length; | 6956 contents.byte_length_ = byte_length; |
| 6930 return contents; | 6957 return contents; |
| 6931 } | 6958 } |
| 6932 | 6959 |
| 6933 | 6960 |
| 6934 size_t v8::SharedArrayBuffer::ByteLength() const { | 6961 size_t v8::SharedArrayBuffer::ByteLength() const { |
| 6935 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6962 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6936 return static_cast<size_t>(obj->byte_length()->Number()); | 6963 return static_cast<size_t>(obj->byte_length()->Number()); |
| 6937 } | 6964 } |
| 6938 | 6965 |
| 6939 | 6966 |
| 6940 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, | 6967 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New(Isolate* isolate, |
| 6941 size_t byte_length) { | 6968 size_t byte_length) { |
| 6942 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6969 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 6943 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6970 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6944 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(size_t)"); | 6971 LOG_API(i_isolate, v8_SharedArrayBuffer_New, "v8::SharedArrayBuffer::New"); |
| 6945 ENTER_V8(i_isolate); | 6972 ENTER_V8(i_isolate); |
| 6946 i::Handle<i::JSArrayBuffer> obj = | 6973 i::Handle<i::JSArrayBuffer> obj = |
| 6947 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6974 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
| 6948 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, | 6975 i::JSArrayBuffer::SetupAllocatingData(obj, i_isolate, byte_length, true, |
| 6949 i::SharedFlag::kShared); | 6976 i::SharedFlag::kShared); |
| 6950 return Utils::ToLocalShared(obj); | 6977 return Utils::ToLocalShared(obj); |
| 6951 } | 6978 } |
| 6952 | 6979 |
| 6953 | 6980 |
| 6954 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( | 6981 Local<SharedArrayBuffer> v8::SharedArrayBuffer::New( |
| 6955 Isolate* isolate, void* data, size_t byte_length, | 6982 Isolate* isolate, void* data, size_t byte_length, |
| 6956 ArrayBufferCreationMode mode) { | 6983 ArrayBufferCreationMode mode) { |
| 6957 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6984 CHECK(i::FLAG_harmony_sharedarraybuffer); |
| 6958 // Embedders must guarantee that the external backing store is valid. | 6985 // Embedders must guarantee that the external backing store is valid. |
| 6959 CHECK(byte_length == 0 || data != NULL); | 6986 CHECK(byte_length == 0 || data != NULL); |
| 6960 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6987 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6961 LOG_API(i_isolate, "v8::SharedArrayBuffer::New(void*, size_t)"); | 6988 LOG_API(i_isolate, v8_SharedArrayBuffer_New, "v8::SharedArrayBuffer::New"); |
| 6962 ENTER_V8(i_isolate); | 6989 ENTER_V8(i_isolate); |
| 6963 i::Handle<i::JSArrayBuffer> obj = | 6990 i::Handle<i::JSArrayBuffer> obj = |
| 6964 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); | 6991 i_isolate->factory()->NewJSArrayBuffer(i::SharedFlag::kShared); |
| 6965 i::JSArrayBuffer::Setup(obj, i_isolate, | 6992 i::JSArrayBuffer::Setup(obj, i_isolate, |
| 6966 mode == ArrayBufferCreationMode::kExternalized, data, | 6993 mode == ArrayBufferCreationMode::kExternalized, data, |
| 6967 byte_length, i::SharedFlag::kShared); | 6994 byte_length, i::SharedFlag::kShared); |
| 6968 return Utils::ToLocalShared(obj); | 6995 return Utils::ToLocalShared(obj); |
| 6969 } | 6996 } |
| 6970 | 6997 |
| 6971 | 6998 |
| 6972 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { | 6999 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { |
| 6973 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7000 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6974 LOG_API(i_isolate, "Symbol::New()"); | 7001 LOG_API(i_isolate, Symbol_New, "Symbol::New"); |
| 6975 ENTER_V8(i_isolate); | 7002 ENTER_V8(i_isolate); |
| 6976 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 7003 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
| 6977 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); | 7004 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); |
| 6978 return Utils::ToLocal(result); | 7005 return Utils::ToLocal(result); |
| 6979 } | 7006 } |
| 6980 | 7007 |
| 6981 | 7008 |
| 6982 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, | 7009 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, |
| 6983 i::Handle<i::String> name, | 7010 i::Handle<i::String> name, |
| 6984 i::Handle<i::String> part, | 7011 i::Handle<i::String> part, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7037 | 7064 |
| 7038 | 7065 |
| 7039 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { | 7066 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { |
| 7040 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7067 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7041 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); | 7068 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); |
| 7042 } | 7069 } |
| 7043 | 7070 |
| 7044 | 7071 |
| 7045 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 7072 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
| 7046 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7073 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 7047 LOG_API(i_isolate, "Private::New()"); | 7074 LOG_API(i_isolate, Private_New, "Private::New"); |
| 7048 ENTER_V8(i_isolate); | 7075 ENTER_V8(i_isolate); |
| 7049 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 7076 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
| 7050 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 7077 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
| 7051 Local<Symbol> result = Utils::ToLocal(symbol); | 7078 Local<Symbol> result = Utils::ToLocal(symbol); |
| 7052 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); | 7079 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); |
| 7053 } | 7080 } |
| 7054 | 7081 |
| 7055 | 7082 |
| 7056 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { | 7083 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { |
| 7057 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7084 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7963 length_ = str->Length(); | 7990 length_ = str->Length(); |
| 7964 str_ = i::NewArray<uint16_t>(length_ + 1); | 7991 str_ = i::NewArray<uint16_t>(length_ + 1); |
| 7965 str->Write(str_); | 7992 str->Write(str_); |
| 7966 } | 7993 } |
| 7967 | 7994 |
| 7968 | 7995 |
| 7969 String::Value::~Value() { | 7996 String::Value::~Value() { |
| 7970 i::DeleteArray(str_); | 7997 i::DeleteArray(str_); |
| 7971 } | 7998 } |
| 7972 | 7999 |
| 7973 | |
| 7974 #define DEFINE_ERROR(NAME, name) \ | 8000 #define DEFINE_ERROR(NAME, name) \ |
| 7975 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ | 8001 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ |
| 7976 i::Isolate* isolate = i::Isolate::Current(); \ | 8002 i::Isolate* isolate = i::Isolate::Current(); \ |
| 7977 LOG_API(isolate, #NAME); \ | 8003 LOG_API(isolate, NAME, #NAME); \ |
| 7978 ENTER_V8(isolate); \ | 8004 ENTER_V8(isolate); \ |
| 7979 i::Object* error; \ | 8005 i::Object* error; \ |
| 7980 { \ | 8006 { \ |
| 7981 i::HandleScope scope(isolate); \ | 8007 i::HandleScope scope(isolate); \ |
| 7982 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ | 8008 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ |
| 7983 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \ | 8009 i::Handle<i::JSFunction> constructor = isolate->name##_function(); \ |
| 7984 error = *isolate->factory()->NewError(constructor, message); \ | 8010 error = *isolate->factory()->NewError(constructor, message); \ |
| 7985 } \ | 8011 } \ |
| 7986 i::Handle<i::Object> result(error, isolate); \ | 8012 i::Handle<i::Object> result(error, isolate); \ |
| 7987 return Utils::ToLocal(result); \ | 8013 return Utils::ToLocal(result); \ |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8083 ClientData* client_data) { | 8109 ClientData* client_data) { |
| 8084 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 8110 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 8085 internal_isolate->debug()->EnqueueCommandMessage( | 8111 internal_isolate->debug()->EnqueueCommandMessage( |
| 8086 i::Vector<const uint16_t>(command, length), client_data); | 8112 i::Vector<const uint16_t>(command, length), client_data); |
| 8087 } | 8113 } |
| 8088 | 8114 |
| 8089 | 8115 |
| 8090 MaybeLocal<Value> Debug::Call(Local<Context> context, | 8116 MaybeLocal<Value> Debug::Call(Local<Context> context, |
| 8091 v8::Local<v8::Function> fun, | 8117 v8::Local<v8::Function> fun, |
| 8092 v8::Local<v8::Value> data) { | 8118 v8::Local<v8::Value> data) { |
| 8093 PREPARE_FOR_EXECUTION(context, "v8::Debug::Call()", Value); | 8119 PREPARE_FOR_EXECUTION(context, v8_Debug_Call, "v8::Debug::Call", Value); |
| 8094 i::Handle<i::Object> data_obj; | 8120 i::Handle<i::Object> data_obj; |
| 8095 if (data.IsEmpty()) { | 8121 if (data.IsEmpty()) { |
| 8096 data_obj = isolate->factory()->undefined_value(); | 8122 data_obj = isolate->factory()->undefined_value(); |
| 8097 } else { | 8123 } else { |
| 8098 data_obj = Utils::OpenHandle(*data); | 8124 data_obj = Utils::OpenHandle(*data); |
| 8099 } | 8125 } |
| 8100 Local<Value> result; | 8126 Local<Value> result; |
| 8101 has_pending_exception = | 8127 has_pending_exception = |
| 8102 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), | 8128 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), |
| 8103 &result); | 8129 &result); |
| 8104 RETURN_ON_FAILED_EXECUTION(Value); | 8130 RETURN_ON_FAILED_EXECUTION(Value); |
| 8105 RETURN_ESCAPED(result); | 8131 RETURN_ESCAPED(result); |
| 8106 } | 8132 } |
| 8107 | 8133 |
| 8108 | 8134 |
| 8109 Local<Value> Debug::Call(v8::Local<v8::Function> fun, | 8135 Local<Value> Debug::Call(v8::Local<v8::Function> fun, |
| 8110 v8::Local<v8::Value> data) { | 8136 v8::Local<v8::Value> data) { |
| 8111 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); | 8137 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); |
| 8112 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); | 8138 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); |
| 8113 } | 8139 } |
| 8114 | 8140 |
| 8115 | 8141 |
| 8116 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, | 8142 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, |
| 8117 v8::Local<v8::Value> obj) { | 8143 v8::Local<v8::Value> obj) { |
| 8118 PREPARE_FOR_EXECUTION(context, "v8::Debug::GetMirror()", Value); | 8144 PREPARE_FOR_EXECUTION(context, v8_Debug_GetMirror, "v8::Debug::GetMirror", |
| 8145 Value); | |
| 8119 i::Debug* isolate_debug = isolate->debug(); | 8146 i::Debug* isolate_debug = isolate->debug(); |
| 8120 has_pending_exception = !isolate_debug->Load(); | 8147 has_pending_exception = !isolate_debug->Load(); |
| 8121 RETURN_ON_FAILED_EXECUTION(Value); | 8148 RETURN_ON_FAILED_EXECUTION(Value); |
| 8122 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 8149 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
| 8123 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); | 8150 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); |
| 8124 auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked(); | 8151 auto fun_obj = i::JSReceiver::GetProperty(debug, name).ToHandleChecked(); |
| 8125 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); | 8152 auto v8_fun = Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); |
| 8126 const int kArgc = 1; | 8153 const int kArgc = 1; |
| 8127 v8::Local<v8::Value> argv[kArgc] = {obj}; | 8154 v8::Local<v8::Value> argv[kArgc] = {obj}; |
| 8128 Local<Value> result; | 8155 Local<Value> result; |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8828 } | 8855 } |
| 8829 } | 8856 } |
| 8830 | 8857 |
| 8831 | 8858 |
| 8832 void InvokeAccessorGetterCallback( | 8859 void InvokeAccessorGetterCallback( |
| 8833 v8::Local<v8::Name> property, | 8860 v8::Local<v8::Name> property, |
| 8834 const v8::PropertyCallbackInfo<v8::Value>& info, | 8861 const v8::PropertyCallbackInfo<v8::Value>& info, |
| 8835 v8::AccessorNameGetterCallback getter) { | 8862 v8::AccessorNameGetterCallback getter) { |
| 8836 // Leaving JavaScript. | 8863 // Leaving JavaScript. |
| 8837 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8864 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8865 RuntimeCallTimerScope timer( | |
| 8866 isolate, | |
| 8867 &isolate->counters()->runtime_call_stats()->AccessorGetterCallback); | |
| 8838 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( | 8868 Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>( |
| 8839 getter)); | 8869 getter)); |
| 8840 VMState<EXTERNAL> state(isolate); | 8870 VMState<EXTERNAL> state(isolate); |
| 8841 ExternalCallbackScope call_scope(isolate, getter_address); | 8871 ExternalCallbackScope call_scope(isolate, getter_address); |
| 8842 getter(property, info); | 8872 getter(property, info); |
| 8843 } | 8873 } |
| 8844 | 8874 |
| 8845 | 8875 |
| 8846 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, | 8876 void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info, |
| 8847 v8::FunctionCallback callback) { | 8877 v8::FunctionCallback callback) { |
| 8848 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8878 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8879 RuntimeCallTimerScope timer( | |
| 8880 isolate, | |
| 8881 &isolate->counters()->runtime_call_stats()->InvokeFunctionCallback); | |
| 8849 Address callback_address = | 8882 Address callback_address = |
| 8850 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8883 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8851 VMState<EXTERNAL> state(isolate); | 8884 VMState<EXTERNAL> state(isolate); |
| 8852 ExternalCallbackScope call_scope(isolate, callback_address); | 8885 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8853 callback(info); | 8886 callback(info); |
| 8854 } | 8887 } |
| 8855 | 8888 |
| 8856 | 8889 |
| 8857 } // namespace internal | 8890 } // namespace internal |
| 8858 } // namespace v8 | 8891 } // namespace v8 |
| OLD | NEW |