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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 { | 366 { |
367 base::ElapsedTimer timer; | 367 base::ElapsedTimer timer; |
368 timer.Start(); | 368 timer.Start(); |
369 Isolate::Scope isolate_scope(isolate); | 369 Isolate::Scope isolate_scope(isolate); |
370 internal_isolate->set_creating_default_snapshot(true); | 370 internal_isolate->set_creating_default_snapshot(true); |
371 internal_isolate->Init(NULL); | 371 internal_isolate->Init(NULL); |
372 Persistent<Context> context; | 372 Persistent<Context> context; |
373 i::Snapshot::Metadata metadata; | 373 i::Snapshot::Metadata metadata; |
374 { | 374 { |
375 HandleScope handle_scope(isolate); | 375 HandleScope handle_scope(isolate); |
376 Handle<Context> new_context = Context::New(isolate); | 376 Local<Context> new_context = Context::New(isolate); |
377 internal_isolate->set_creating_default_snapshot(false); | 377 internal_isolate->set_creating_default_snapshot(false); |
378 context.Reset(isolate, new_context); | 378 context.Reset(isolate, new_context); |
379 if (custom_source != NULL) { | 379 if (custom_source != NULL) { |
380 metadata.set_embeds_script(true); | 380 metadata.set_embeds_script(true); |
381 Context::Scope context_scope(new_context); | 381 Context::Scope context_scope(new_context); |
382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); | 382 if (!RunExtraCode(isolate, new_context, custom_source)) context.Reset(); |
383 } | 383 } |
384 } | 384 } |
385 if (!context.IsEmpty()) { | 385 if (!context.IsEmpty()) { |
386 // Make sure all builtin scripts are cached. | 386 // Make sure all builtin scripts are cached. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 | 802 |
803 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) { | 803 v8::Local<v8::Value> Context::SlowGetEmbedderData(int index) { |
804 const char* location = "v8::Context::GetEmbedderData()"; | 804 const char* location = "v8::Context::GetEmbedderData()"; |
805 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location); | 805 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, false, location); |
806 if (data.is_null()) return Local<Value>(); | 806 if (data.is_null()) return Local<Value>(); |
807 i::Handle<i::Object> result(data->get(index), data->GetIsolate()); | 807 i::Handle<i::Object> result(data->get(index), data->GetIsolate()); |
808 return Utils::ToLocal(result); | 808 return Utils::ToLocal(result); |
809 } | 809 } |
810 | 810 |
811 | 811 |
812 void Context::SetEmbedderData(int index, v8::Handle<Value> value) { | 812 void Context::SetEmbedderData(int index, v8::Local<Value> value) { |
813 const char* location = "v8::Context::SetEmbedderData()"; | 813 const char* location = "v8::Context::SetEmbedderData()"; |
814 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); | 814 i::Handle<i::FixedArray> data = EmbedderDataFor(this, index, true, location); |
815 if (data.is_null()) return; | 815 if (data.is_null()) return; |
816 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 816 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
817 data->set(index, *val); | 817 data->set(index, *val); |
818 DCHECK_EQ(*Utils::OpenHandle(*value), | 818 DCHECK_EQ(*Utils::OpenHandle(*value), |
819 *Utils::OpenHandle(*GetEmbedderData(index))); | 819 *Utils::OpenHandle(*GetEmbedderData(index))); |
820 } | 820 } |
821 | 821 |
822 | 822 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 902 |
903 // --- T e m p l a t e --- | 903 // --- T e m p l a t e --- |
904 | 904 |
905 | 905 |
906 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { | 906 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { |
907 that->set_number_of_properties(0); | 907 that->set_number_of_properties(0); |
908 that->set_tag(i::Smi::FromInt(type)); | 908 that->set_tag(i::Smi::FromInt(type)); |
909 } | 909 } |
910 | 910 |
911 | 911 |
912 void Template::Set(v8::Handle<Name> name, | 912 void Template::Set(v8::Local<Name> name, v8::Local<Data> value, |
913 v8::Handle<Data> value, | |
914 v8::PropertyAttribute attribute) { | 913 v8::PropertyAttribute attribute) { |
915 auto templ = Utils::OpenHandle(this); | 914 auto templ = Utils::OpenHandle(this); |
916 i::Isolate* isolate = templ->GetIsolate(); | 915 i::Isolate* isolate = templ->GetIsolate(); |
917 ENTER_V8(isolate); | 916 ENTER_V8(isolate); |
918 i::HandleScope scope(isolate); | 917 i::HandleScope scope(isolate); |
919 // TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo. | 918 // TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo. |
920 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), | 919 i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name), |
921 Utils::OpenHandle(*value), | 920 Utils::OpenHandle(*value), |
922 static_cast<PropertyAttributes>(attribute)); | 921 static_cast<PropertyAttributes>(attribute)); |
923 } | 922 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 } | 965 } |
967 | 966 |
968 | 967 |
969 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info, | 968 static void EnsureNotInstantiated(i::Handle<i::FunctionTemplateInfo> info, |
970 const char* func) { | 969 const char* func) { |
971 Utils::ApiCheck(!info->instantiated(), func, | 970 Utils::ApiCheck(!info->instantiated(), func, |
972 "FunctionTemplate already instantiated"); | 971 "FunctionTemplate already instantiated"); |
973 } | 972 } |
974 | 973 |
975 | 974 |
976 void FunctionTemplate::Inherit(v8::Handle<FunctionTemplate> value) { | 975 void FunctionTemplate::Inherit(v8::Local<FunctionTemplate> value) { |
977 auto info = Utils::OpenHandle(this); | 976 auto info = Utils::OpenHandle(this); |
978 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit"); | 977 EnsureNotInstantiated(info, "v8::FunctionTemplate::Inherit"); |
979 i::Isolate* isolate = info->GetIsolate(); | 978 i::Isolate* isolate = info->GetIsolate(); |
980 ENTER_V8(isolate); | 979 ENTER_V8(isolate); |
981 info->set_parent_template(*Utils::OpenHandle(*value)); | 980 info->set_parent_template(*Utils::OpenHandle(*value)); |
982 } | 981 } |
983 | 982 |
984 | 983 |
985 static Local<FunctionTemplate> FunctionTemplateNew( | 984 static Local<FunctionTemplate> FunctionTemplateNew( |
986 i::Isolate* isolate, | 985 i::Isolate* isolate, FunctionCallback callback, v8::Local<Value> data, |
987 FunctionCallback callback, | 986 v8::Local<Signature> signature, int length, bool do_not_cache) { |
988 v8::Handle<Value> data, | |
989 v8::Handle<Signature> signature, | |
990 int length, | |
991 bool do_not_cache) { | |
992 i::Handle<i::Struct> struct_obj = | 987 i::Handle<i::Struct> struct_obj = |
993 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); | 988 isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); |
994 i::Handle<i::FunctionTemplateInfo> obj = | 989 i::Handle<i::FunctionTemplateInfo> obj = |
995 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); | 990 i::Handle<i::FunctionTemplateInfo>::cast(struct_obj); |
996 InitializeFunctionTemplate(obj); | 991 InitializeFunctionTemplate(obj); |
997 obj->set_do_not_cache(do_not_cache); | 992 obj->set_do_not_cache(do_not_cache); |
998 int next_serial_number = 0; | 993 int next_serial_number = 0; |
999 if (!do_not_cache) { | 994 if (!do_not_cache) { |
1000 next_serial_number = isolate->next_serial_number() + 1; | 995 next_serial_number = isolate->next_serial_number() + 1; |
1001 isolate->set_next_serial_number(next_serial_number); | 996 isolate->set_next_serial_number(next_serial_number); |
1002 } | 997 } |
1003 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); | 998 obj->set_serial_number(i::Smi::FromInt(next_serial_number)); |
1004 if (callback != 0) { | 999 if (callback != 0) { |
1005 if (data.IsEmpty()) { | 1000 if (data.IsEmpty()) { |
1006 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1001 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1007 } | 1002 } |
1008 Utils::ToLocal(obj)->SetCallHandler(callback, data); | 1003 Utils::ToLocal(obj)->SetCallHandler(callback, data); |
1009 } | 1004 } |
1010 obj->set_length(length); | 1005 obj->set_length(length); |
1011 obj->set_undetectable(false); | 1006 obj->set_undetectable(false); |
1012 obj->set_needs_access_check(false); | 1007 obj->set_needs_access_check(false); |
1013 obj->set_accept_any_receiver(true); | 1008 obj->set_accept_any_receiver(true); |
1014 if (!signature.IsEmpty()) | 1009 if (!signature.IsEmpty()) |
1015 obj->set_signature(*Utils::OpenHandle(*signature)); | 1010 obj->set_signature(*Utils::OpenHandle(*signature)); |
1016 return Utils::ToLocal(obj); | 1011 return Utils::ToLocal(obj); |
1017 } | 1012 } |
1018 | 1013 |
1019 Local<FunctionTemplate> FunctionTemplate::New( | 1014 Local<FunctionTemplate> FunctionTemplate::New(Isolate* isolate, |
1020 Isolate* isolate, | 1015 FunctionCallback callback, |
1021 FunctionCallback callback, | 1016 v8::Local<Value> data, |
1022 v8::Handle<Value> data, | 1017 v8::Local<Signature> signature, |
1023 v8::Handle<Signature> signature, | 1018 int length) { |
1024 int length) { | |
1025 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1019 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1026 // Changes to the environment cannot be captured in the snapshot. Expect no | 1020 // Changes to the environment cannot be captured in the snapshot. Expect no |
1027 // function templates when the isolate is created for serialization. | 1021 // function templates when the isolate is created for serialization. |
1028 DCHECK(!i_isolate->serializer_enabled()); | 1022 DCHECK(!i_isolate->serializer_enabled()); |
1029 LOG_API(i_isolate, "FunctionTemplate::New"); | 1023 LOG_API(i_isolate, "FunctionTemplate::New"); |
1030 ENTER_V8(i_isolate); | 1024 ENTER_V8(i_isolate); |
1031 return FunctionTemplateNew( | 1025 return FunctionTemplateNew( |
1032 i_isolate, callback, data, signature, length, false); | 1026 i_isolate, callback, data, signature, length, false); |
1033 } | 1027 } |
1034 | 1028 |
1035 | 1029 |
1036 Local<Signature> Signature::New(Isolate* isolate, | 1030 Local<Signature> Signature::New(Isolate* isolate, |
1037 Handle<FunctionTemplate> receiver) { | 1031 Local<FunctionTemplate> receiver) { |
1038 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); | 1032 return Utils::SignatureToLocal(Utils::OpenHandle(*receiver)); |
1039 } | 1033 } |
1040 | 1034 |
1041 | 1035 |
1042 Local<AccessorSignature> AccessorSignature::New( | 1036 Local<AccessorSignature> AccessorSignature::New( |
1043 Isolate* isolate, | 1037 Isolate* isolate, Local<FunctionTemplate> receiver) { |
1044 Handle<FunctionTemplate> receiver) { | |
1045 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 1038 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
1046 } | 1039 } |
1047 | 1040 |
1048 | 1041 |
1049 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { | 1042 Local<TypeSwitch> TypeSwitch::New(Local<FunctionTemplate> type) { |
1050 Handle<FunctionTemplate> types[1] = { type }; | 1043 Local<FunctionTemplate> types[1] = {type}; |
1051 return TypeSwitch::New(1, types); | 1044 return TypeSwitch::New(1, types); |
1052 } | 1045 } |
1053 | 1046 |
1054 | 1047 |
1055 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { | 1048 Local<TypeSwitch> TypeSwitch::New(int argc, Local<FunctionTemplate> types[]) { |
1056 i::Isolate* isolate = i::Isolate::Current(); | 1049 i::Isolate* isolate = i::Isolate::Current(); |
1057 LOG_API(isolate, "TypeSwitch::New"); | 1050 LOG_API(isolate, "TypeSwitch::New"); |
1058 ENTER_V8(isolate); | 1051 ENTER_V8(isolate); |
1059 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc); | 1052 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc); |
1060 for (int i = 0; i < argc; i++) | 1053 for (int i = 0; i < argc; i++) |
1061 vector->set(i, *Utils::OpenHandle(*types[i])); | 1054 vector->set(i, *Utils::OpenHandle(*types[i])); |
1062 i::Handle<i::Struct> struct_obj = | 1055 i::Handle<i::Struct> struct_obj = |
1063 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE); | 1056 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE); |
1064 i::Handle<i::TypeSwitchInfo> obj = | 1057 i::Handle<i::TypeSwitchInfo> obj = |
1065 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); | 1058 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); |
1066 obj->set_types(*vector); | 1059 obj->set_types(*vector); |
1067 return Utils::ToLocal(obj); | 1060 return Utils::ToLocal(obj); |
1068 } | 1061 } |
1069 | 1062 |
1070 | 1063 |
1071 int TypeSwitch::match(v8::Handle<Value> value) { | 1064 int TypeSwitch::match(v8::Local<Value> value) { |
1072 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); | 1065 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); |
1073 LOG_API(info->GetIsolate(), "TypeSwitch::match"); | 1066 LOG_API(info->GetIsolate(), "TypeSwitch::match"); |
1074 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 1067 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
1075 i::FixedArray* types = i::FixedArray::cast(info->types()); | 1068 i::FixedArray* types = i::FixedArray::cast(info->types()); |
1076 for (int i = 0; i < types->length(); i++) { | 1069 for (int i = 0; i < types->length(); i++) { |
1077 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj)) | 1070 if (i::FunctionTemplateInfo::cast(types->get(i))->IsTemplateFor(*obj)) |
1078 return i + 1; | 1071 return i + 1; |
1079 } | 1072 } |
1080 return 0; | 1073 return 0; |
1081 } | 1074 } |
1082 | 1075 |
1083 | 1076 |
1084 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ | 1077 #define SET_FIELD_WRAPPED(obj, setter, cdata) do { \ |
1085 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ | 1078 i::Handle<i::Object> foreign = FromCData(obj->GetIsolate(), cdata); \ |
1086 (obj)->setter(*foreign); \ | 1079 (obj)->setter(*foreign); \ |
1087 } while (false) | 1080 } while (false) |
1088 | 1081 |
1089 | 1082 |
1090 void FunctionTemplate::SetCallHandler(FunctionCallback callback, | 1083 void FunctionTemplate::SetCallHandler(FunctionCallback callback, |
1091 v8::Handle<Value> data) { | 1084 v8::Local<Value> data) { |
1092 auto info = Utils::OpenHandle(this); | 1085 auto info = Utils::OpenHandle(this); |
1093 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); | 1086 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); |
1094 i::Isolate* isolate = info->GetIsolate(); | 1087 i::Isolate* isolate = info->GetIsolate(); |
1095 ENTER_V8(isolate); | 1088 ENTER_V8(isolate); |
1096 i::HandleScope scope(isolate); | 1089 i::HandleScope scope(isolate); |
1097 i::Handle<i::Struct> struct_obj = | 1090 i::Handle<i::Struct> struct_obj = |
1098 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1091 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
1099 i::Handle<i::CallHandlerInfo> obj = | 1092 i::Handle<i::CallHandlerInfo> obj = |
1100 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1093 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1101 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1094 SET_FIELD_WRAPPED(obj, set_callback, callback); |
1102 if (data.IsEmpty()) { | 1095 if (data.IsEmpty()) { |
1103 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1096 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1104 } | 1097 } |
1105 obj->set_data(*Utils::OpenHandle(*data)); | 1098 obj->set_data(*Utils::OpenHandle(*data)); |
1106 info->set_call_code(*obj); | 1099 info->set_call_code(*obj); |
1107 } | 1100 } |
1108 | 1101 |
1109 | 1102 |
1110 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( | 1103 static i::Handle<i::AccessorInfo> SetAccessorInfoProperties( |
1111 i::Handle<i::AccessorInfo> obj, | 1104 i::Handle<i::AccessorInfo> obj, v8::Local<Name> name, |
1112 v8::Handle<Name> name, | 1105 v8::AccessControl settings, v8::PropertyAttribute attributes, |
1113 v8::AccessControl settings, | 1106 v8::Local<AccessorSignature> signature) { |
1114 v8::PropertyAttribute attributes, | |
1115 v8::Handle<AccessorSignature> signature) { | |
1116 obj->set_name(*Utils::OpenHandle(*name)); | 1107 obj->set_name(*Utils::OpenHandle(*name)); |
1117 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); | 1108 if (settings & ALL_CAN_READ) obj->set_all_can_read(true); |
1118 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); | 1109 if (settings & ALL_CAN_WRITE) obj->set_all_can_write(true); |
1119 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); | 1110 obj->set_property_attributes(static_cast<PropertyAttributes>(attributes)); |
1120 if (!signature.IsEmpty()) { | 1111 if (!signature.IsEmpty()) { |
1121 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); | 1112 obj->set_expected_receiver_type(*Utils::OpenHandle(*signature)); |
1122 } | 1113 } |
1123 return obj; | 1114 return obj; |
1124 } | 1115 } |
1125 | 1116 |
1126 | 1117 |
1127 template<typename Getter, typename Setter> | 1118 template <typename Getter, typename Setter> |
1128 static i::Handle<i::AccessorInfo> MakeAccessorInfo( | 1119 static i::Handle<i::AccessorInfo> MakeAccessorInfo( |
1129 v8::Handle<Name> name, | 1120 v8::Local<Name> name, Getter getter, Setter setter, v8::Local<Value> data, |
1130 Getter getter, | 1121 v8::AccessControl settings, v8::PropertyAttribute attributes, |
1131 Setter setter, | 1122 v8::Local<AccessorSignature> signature) { |
1132 v8::Handle<Value> data, | |
1133 v8::AccessControl settings, | |
1134 v8::PropertyAttribute attributes, | |
1135 v8::Handle<AccessorSignature> signature) { | |
1136 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); | 1123 i::Isolate* isolate = Utils::OpenHandle(*name)->GetIsolate(); |
1137 i::Handle<i::ExecutableAccessorInfo> obj = | 1124 i::Handle<i::ExecutableAccessorInfo> obj = |
1138 isolate->factory()->NewExecutableAccessorInfo(); | 1125 isolate->factory()->NewExecutableAccessorInfo(); |
1139 SET_FIELD_WRAPPED(obj, set_getter, getter); | 1126 SET_FIELD_WRAPPED(obj, set_getter, getter); |
1140 SET_FIELD_WRAPPED(obj, set_setter, setter); | 1127 SET_FIELD_WRAPPED(obj, set_setter, setter); |
1141 if (data.IsEmpty()) { | 1128 if (data.IsEmpty()) { |
1142 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1129 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1143 } | 1130 } |
1144 obj->set_data(*Utils::OpenHandle(*data)); | 1131 obj->set_data(*Utils::OpenHandle(*data)); |
1145 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); | 1132 return SetAccessorInfoProperties(obj, name, settings, attributes, signature); |
(...skipping 22 matching lines...) Expand all Loading... |
1168 | 1155 |
1169 void FunctionTemplate::SetLength(int length) { | 1156 void FunctionTemplate::SetLength(int length) { |
1170 auto info = Utils::OpenHandle(this); | 1157 auto info = Utils::OpenHandle(this); |
1171 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetLength"); | 1158 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetLength"); |
1172 auto isolate = info->GetIsolate(); | 1159 auto isolate = info->GetIsolate(); |
1173 ENTER_V8(isolate); | 1160 ENTER_V8(isolate); |
1174 info->set_length(length); | 1161 info->set_length(length); |
1175 } | 1162 } |
1176 | 1163 |
1177 | 1164 |
1178 void FunctionTemplate::SetClassName(Handle<String> name) { | 1165 void FunctionTemplate::SetClassName(Local<String> name) { |
1179 auto info = Utils::OpenHandle(this); | 1166 auto info = Utils::OpenHandle(this); |
1180 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetClassName"); | 1167 EnsureNotInstantiated(info, "v8::FunctionTemplate::SetClassName"); |
1181 auto isolate = info->GetIsolate(); | 1168 auto isolate = info->GetIsolate(); |
1182 ENTER_V8(isolate); | 1169 ENTER_V8(isolate); |
1183 info->set_class_name(*Utils::OpenHandle(*name)); | 1170 info->set_class_name(*Utils::OpenHandle(*name)); |
1184 } | 1171 } |
1185 | 1172 |
1186 | 1173 |
1187 void FunctionTemplate::SetAcceptAnyReceiver(bool value) { | 1174 void FunctionTemplate::SetAcceptAnyReceiver(bool value) { |
1188 auto info = Utils::OpenHandle(this); | 1175 auto info = Utils::OpenHandle(this); |
(...skipping 28 matching lines...) Expand all Loading... |
1217 auto isolate = info->GetIsolate(); | 1204 auto isolate = info->GetIsolate(); |
1218 ENTER_V8(isolate); | 1205 ENTER_V8(isolate); |
1219 info->set_remove_prototype(true); | 1206 info->set_remove_prototype(true); |
1220 } | 1207 } |
1221 | 1208 |
1222 | 1209 |
1223 // --- O b j e c t T e m p l a t e --- | 1210 // --- O b j e c t T e m p l a t e --- |
1224 | 1211 |
1225 | 1212 |
1226 Local<ObjectTemplate> ObjectTemplate::New( | 1213 Local<ObjectTemplate> ObjectTemplate::New( |
1227 Isolate* isolate, v8::Handle<FunctionTemplate> constructor) { | 1214 Isolate* isolate, v8::Local<FunctionTemplate> constructor) { |
1228 return New(reinterpret_cast<i::Isolate*>(isolate), constructor); | 1215 return New(reinterpret_cast<i::Isolate*>(isolate), constructor); |
1229 } | 1216 } |
1230 | 1217 |
1231 | 1218 |
1232 Local<ObjectTemplate> ObjectTemplate::New() { | 1219 Local<ObjectTemplate> ObjectTemplate::New() { |
1233 return New(i::Isolate::Current(), Local<FunctionTemplate>()); | 1220 return New(i::Isolate::Current(), Local<FunctionTemplate>()); |
1234 } | 1221 } |
1235 | 1222 |
1236 | 1223 |
1237 Local<ObjectTemplate> ObjectTemplate::New( | 1224 Local<ObjectTemplate> ObjectTemplate::New( |
1238 i::Isolate* isolate, | 1225 i::Isolate* isolate, v8::Local<FunctionTemplate> constructor) { |
1239 v8::Handle<FunctionTemplate> constructor) { | |
1240 // Changes to the environment cannot be captured in the snapshot. Expect no | 1226 // Changes to the environment cannot be captured in the snapshot. Expect no |
1241 // object templates when the isolate is created for serialization. | 1227 // object templates when the isolate is created for serialization. |
1242 DCHECK(!isolate->serializer_enabled()); | 1228 DCHECK(!isolate->serializer_enabled()); |
1243 LOG_API(isolate, "ObjectTemplate::New"); | 1229 LOG_API(isolate, "ObjectTemplate::New"); |
1244 ENTER_V8(isolate); | 1230 ENTER_V8(isolate); |
1245 i::Handle<i::Struct> struct_obj = | 1231 i::Handle<i::Struct> struct_obj = |
1246 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1232 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
1247 i::Handle<i::ObjectTemplateInfo> obj = | 1233 i::Handle<i::ObjectTemplateInfo> obj = |
1248 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1234 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1249 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1235 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 if (obj.is_null()) return false; | 1293 if (obj.is_null()) return false; |
1308 auto info = GetTemplateInfo(isolate, template_obj); | 1294 auto info = GetTemplateInfo(isolate, template_obj); |
1309 i::ApiNatives::AddNativeDataProperty(isolate, info, obj); | 1295 i::ApiNatives::AddNativeDataProperty(isolate, info, obj); |
1310 return true; | 1296 return true; |
1311 } | 1297 } |
1312 | 1298 |
1313 | 1299 |
1314 void Template::SetNativeDataProperty(v8::Local<String> name, | 1300 void Template::SetNativeDataProperty(v8::Local<String> name, |
1315 AccessorGetterCallback getter, | 1301 AccessorGetterCallback getter, |
1316 AccessorSetterCallback setter, | 1302 AccessorSetterCallback setter, |
1317 v8::Handle<Value> data, | 1303 v8::Local<Value> data, |
1318 PropertyAttribute attribute, | 1304 PropertyAttribute attribute, |
1319 v8::Local<AccessorSignature> signature, | 1305 v8::Local<AccessorSignature> signature, |
1320 AccessControl settings) { | 1306 AccessControl settings) { |
1321 TemplateSetAccessor( | 1307 TemplateSetAccessor( |
1322 this, name, getter, setter, data, settings, attribute, signature); | 1308 this, name, getter, setter, data, settings, attribute, signature); |
1323 } | 1309 } |
1324 | 1310 |
1325 | 1311 |
1326 void Template::SetNativeDataProperty(v8::Local<Name> name, | 1312 void Template::SetNativeDataProperty(v8::Local<Name> name, |
1327 AccessorNameGetterCallback getter, | 1313 AccessorNameGetterCallback getter, |
1328 AccessorNameSetterCallback setter, | 1314 AccessorNameSetterCallback setter, |
1329 v8::Handle<Value> data, | 1315 v8::Local<Value> data, |
1330 PropertyAttribute attribute, | 1316 PropertyAttribute attribute, |
1331 v8::Local<AccessorSignature> signature, | 1317 v8::Local<AccessorSignature> signature, |
1332 AccessControl settings) { | 1318 AccessControl settings) { |
1333 TemplateSetAccessor( | 1319 TemplateSetAccessor( |
1334 this, name, getter, setter, data, settings, attribute, signature); | 1320 this, name, getter, setter, data, settings, attribute, signature); |
1335 } | 1321 } |
1336 | 1322 |
1337 | 1323 |
1338 void ObjectTemplate::SetAccessor(v8::Handle<String> name, | 1324 void ObjectTemplate::SetAccessor(v8::Local<String> name, |
1339 AccessorGetterCallback getter, | 1325 AccessorGetterCallback getter, |
1340 AccessorSetterCallback setter, | 1326 AccessorSetterCallback setter, |
1341 v8::Handle<Value> data, | 1327 v8::Local<Value> data, AccessControl settings, |
1342 AccessControl settings, | |
1343 PropertyAttribute attribute, | 1328 PropertyAttribute attribute, |
1344 v8::Handle<AccessorSignature> signature) { | 1329 v8::Local<AccessorSignature> signature) { |
1345 TemplateSetAccessor( | 1330 TemplateSetAccessor( |
1346 this, name, getter, setter, data, settings, attribute, signature); | 1331 this, name, getter, setter, data, settings, attribute, signature); |
1347 } | 1332 } |
1348 | 1333 |
1349 | 1334 |
1350 void ObjectTemplate::SetAccessor(v8::Handle<Name> name, | 1335 void ObjectTemplate::SetAccessor(v8::Local<Name> name, |
1351 AccessorNameGetterCallback getter, | 1336 AccessorNameGetterCallback getter, |
1352 AccessorNameSetterCallback setter, | 1337 AccessorNameSetterCallback setter, |
1353 v8::Handle<Value> data, | 1338 v8::Local<Value> data, AccessControl settings, |
1354 AccessControl settings, | |
1355 PropertyAttribute attribute, | 1339 PropertyAttribute attribute, |
1356 v8::Handle<AccessorSignature> signature) { | 1340 v8::Local<AccessorSignature> signature) { |
1357 TemplateSetAccessor( | 1341 TemplateSetAccessor( |
1358 this, name, getter, setter, data, settings, attribute, signature); | 1342 this, name, getter, setter, data, settings, attribute, signature); |
1359 } | 1343 } |
1360 | 1344 |
1361 | 1345 |
1362 template <typename Getter, typename Setter, typename Query, typename Deleter, | 1346 template <typename Getter, typename Setter, typename Query, typename Deleter, |
1363 typename Enumerator> | 1347 typename Enumerator> |
1364 static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ, | 1348 static void ObjectTemplateSetNamedPropertyHandler(ObjectTemplate* templ, |
1365 Getter getter, Setter setter, | 1349 Getter getter, Setter setter, |
1366 Query query, Deleter remover, | 1350 Query query, Deleter remover, |
1367 Enumerator enumerator, | 1351 Enumerator enumerator, |
1368 Handle<Value> data, | 1352 Local<Value> data, |
1369 PropertyHandlerFlags flags) { | 1353 PropertyHandlerFlags flags) { |
1370 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); | 1354 i::Isolate* isolate = Utils::OpenHandle(templ)->GetIsolate(); |
1371 ENTER_V8(isolate); | 1355 ENTER_V8(isolate); |
1372 i::HandleScope scope(isolate); | 1356 i::HandleScope scope(isolate); |
1373 auto cons = EnsureConstructor(isolate, templ); | 1357 auto cons = EnsureConstructor(isolate, templ); |
1374 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler"); | 1358 EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler"); |
1375 auto obj = i::Handle<i::InterceptorInfo>::cast( | 1359 auto obj = i::Handle<i::InterceptorInfo>::cast( |
1376 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE)); | 1360 isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE)); |
1377 | 1361 |
1378 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); | 1362 if (getter != 0) SET_FIELD_WRAPPED(obj, set_getter, getter); |
(...skipping 14 matching lines...) Expand all Loading... |
1393 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1377 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1394 } | 1378 } |
1395 obj->set_data(*Utils::OpenHandle(*data)); | 1379 obj->set_data(*Utils::OpenHandle(*data)); |
1396 cons->set_named_property_handler(*obj); | 1380 cons->set_named_property_handler(*obj); |
1397 } | 1381 } |
1398 | 1382 |
1399 | 1383 |
1400 void ObjectTemplate::SetNamedPropertyHandler( | 1384 void ObjectTemplate::SetNamedPropertyHandler( |
1401 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, | 1385 NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter, |
1402 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, | 1386 NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover, |
1403 NamedPropertyEnumeratorCallback enumerator, Handle<Value> data) { | 1387 NamedPropertyEnumeratorCallback enumerator, Local<Value> data) { |
1404 ObjectTemplateSetNamedPropertyHandler( | 1388 ObjectTemplateSetNamedPropertyHandler( |
1405 this, getter, setter, query, remover, enumerator, data, | 1389 this, getter, setter, query, remover, enumerator, data, |
1406 PropertyHandlerFlags::kOnlyInterceptStrings); | 1390 PropertyHandlerFlags::kOnlyInterceptStrings); |
1407 } | 1391 } |
1408 | 1392 |
1409 | 1393 |
1410 void ObjectTemplate::SetHandler( | 1394 void ObjectTemplate::SetHandler( |
1411 const NamedPropertyHandlerConfiguration& config) { | 1395 const NamedPropertyHandlerConfiguration& config) { |
1412 ObjectTemplateSetNamedPropertyHandler( | 1396 ObjectTemplateSetNamedPropertyHandler( |
1413 this, config.getter, config.setter, config.query, config.deleter, | 1397 this, config.getter, config.setter, config.query, config.deleter, |
1414 config.enumerator, config.data, config.flags); | 1398 config.enumerator, config.data, config.flags); |
1415 } | 1399 } |
1416 | 1400 |
1417 | 1401 |
1418 void ObjectTemplate::MarkAsUndetectable() { | 1402 void ObjectTemplate::MarkAsUndetectable() { |
1419 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1403 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1420 ENTER_V8(isolate); | 1404 ENTER_V8(isolate); |
1421 i::HandleScope scope(isolate); | 1405 i::HandleScope scope(isolate); |
1422 auto cons = EnsureConstructor(isolate, this); | 1406 auto cons = EnsureConstructor(isolate, this); |
1423 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); | 1407 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); |
1424 cons->set_undetectable(true); | 1408 cons->set_undetectable(true); |
1425 } | 1409 } |
1426 | 1410 |
1427 | 1411 |
1428 void ObjectTemplate::SetAccessCheckCallbacks( | 1412 void ObjectTemplate::SetAccessCheckCallbacks( |
1429 NamedSecurityCallback named_callback, | 1413 NamedSecurityCallback named_callback, |
1430 IndexedSecurityCallback indexed_callback, Handle<Value> data) { | 1414 IndexedSecurityCallback indexed_callback, Local<Value> data) { |
1431 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1415 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1432 ENTER_V8(isolate); | 1416 ENTER_V8(isolate); |
1433 i::HandleScope scope(isolate); | 1417 i::HandleScope scope(isolate); |
1434 auto cons = EnsureConstructor(isolate, this); | 1418 auto cons = EnsureConstructor(isolate, this); |
1435 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallbacks"); | 1419 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallbacks"); |
1436 | 1420 |
1437 i::Handle<i::Struct> struct_info = | 1421 i::Handle<i::Struct> struct_info = |
1438 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1422 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1439 i::Handle<i::AccessCheckInfo> info = | 1423 i::Handle<i::AccessCheckInfo> info = |
1440 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1424 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 v8::Local<v8::Value> data = config.data; | 1460 v8::Local<v8::Value> data = config.data; |
1477 if (data.IsEmpty()) { | 1461 if (data.IsEmpty()) { |
1478 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1462 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1479 } | 1463 } |
1480 obj->set_data(*Utils::OpenHandle(*data)); | 1464 obj->set_data(*Utils::OpenHandle(*data)); |
1481 cons->set_indexed_property_handler(*obj); | 1465 cons->set_indexed_property_handler(*obj); |
1482 } | 1466 } |
1483 | 1467 |
1484 | 1468 |
1485 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, | 1469 void ObjectTemplate::SetCallAsFunctionHandler(FunctionCallback callback, |
1486 Handle<Value> data) { | 1470 Local<Value> data) { |
1487 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1471 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1488 ENTER_V8(isolate); | 1472 ENTER_V8(isolate); |
1489 i::HandleScope scope(isolate); | 1473 i::HandleScope scope(isolate); |
1490 auto cons = EnsureConstructor(isolate, this); | 1474 auto cons = EnsureConstructor(isolate, this); |
1491 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); | 1475 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetCallAsFunctionHandler"); |
1492 i::Handle<i::Struct> struct_obj = | 1476 i::Handle<i::Struct> struct_obj = |
1493 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); | 1477 isolate->factory()->NewStruct(i::CALL_HANDLER_INFO_TYPE); |
1494 i::Handle<i::CallHandlerInfo> obj = | 1478 i::Handle<i::CallHandlerInfo> obj = |
1495 i::Handle<i::CallHandlerInfo>::cast(struct_obj); | 1479 i::Handle<i::CallHandlerInfo>::cast(struct_obj); |
1496 SET_FIELD_WRAPPED(obj, set_callback, callback); | 1480 SET_FIELD_WRAPPED(obj, set_callback, callback); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 LOG_API(isolate, "UnboundScript::GetLineNumber"); | 1610 LOG_API(isolate, "UnboundScript::GetLineNumber"); |
1627 if (obj->script()->IsScript()) { | 1611 if (obj->script()->IsScript()) { |
1628 i::Handle<i::Script> script(i::Script::cast(obj->script())); | 1612 i::Handle<i::Script> script(i::Script::cast(obj->script())); |
1629 return i::Script::GetLineNumber(script, code_pos); | 1613 return i::Script::GetLineNumber(script, code_pos); |
1630 } else { | 1614 } else { |
1631 return -1; | 1615 return -1; |
1632 } | 1616 } |
1633 } | 1617 } |
1634 | 1618 |
1635 | 1619 |
1636 Handle<Value> UnboundScript::GetScriptName() { | 1620 Local<Value> UnboundScript::GetScriptName() { |
1637 i::Handle<i::SharedFunctionInfo> obj = | 1621 i::Handle<i::SharedFunctionInfo> obj = |
1638 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1622 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1639 i::Isolate* isolate = obj->GetIsolate(); | 1623 i::Isolate* isolate = obj->GetIsolate(); |
1640 LOG_API(isolate, "UnboundScript::GetName"); | 1624 LOG_API(isolate, "UnboundScript::GetName"); |
1641 if (obj->script()->IsScript()) { | 1625 if (obj->script()->IsScript()) { |
1642 i::Object* name = i::Script::cast(obj->script())->name(); | 1626 i::Object* name = i::Script::cast(obj->script())->name(); |
1643 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); | 1627 return Utils::ToLocal(i::Handle<i::Object>(name, isolate)); |
1644 } else { | 1628 } else { |
1645 return Handle<String>(); | 1629 return Local<String>(); |
1646 } | 1630 } |
1647 } | 1631 } |
1648 | 1632 |
1649 | 1633 |
1650 Handle<Value> UnboundScript::GetSourceURL() { | 1634 Local<Value> UnboundScript::GetSourceURL() { |
1651 i::Handle<i::SharedFunctionInfo> obj = | 1635 i::Handle<i::SharedFunctionInfo> obj = |
1652 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1636 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1653 i::Isolate* isolate = obj->GetIsolate(); | 1637 i::Isolate* isolate = obj->GetIsolate(); |
1654 LOG_API(isolate, "UnboundScript::GetSourceURL"); | 1638 LOG_API(isolate, "UnboundScript::GetSourceURL"); |
1655 if (obj->script()->IsScript()) { | 1639 if (obj->script()->IsScript()) { |
1656 i::Object* url = i::Script::cast(obj->script())->source_url(); | 1640 i::Object* url = i::Script::cast(obj->script())->source_url(); |
1657 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1641 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
1658 } else { | 1642 } else { |
1659 return Handle<String>(); | 1643 return Local<String>(); |
1660 } | 1644 } |
1661 } | 1645 } |
1662 | 1646 |
1663 | 1647 |
1664 Handle<Value> UnboundScript::GetSourceMappingURL() { | 1648 Local<Value> UnboundScript::GetSourceMappingURL() { |
1665 i::Handle<i::SharedFunctionInfo> obj = | 1649 i::Handle<i::SharedFunctionInfo> obj = |
1666 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); | 1650 i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this)); |
1667 i::Isolate* isolate = obj->GetIsolate(); | 1651 i::Isolate* isolate = obj->GetIsolate(); |
1668 LOG_API(isolate, "UnboundScript::GetSourceMappingURL"); | 1652 LOG_API(isolate, "UnboundScript::GetSourceMappingURL"); |
1669 if (obj->script()->IsScript()) { | 1653 if (obj->script()->IsScript()) { |
1670 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); | 1654 i::Object* url = i::Script::cast(obj->script())->source_mapping_url(); |
1671 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); | 1655 return Utils::ToLocal(i::Handle<i::Object>(url, isolate)); |
1672 } else { | 1656 } else { |
1673 return Handle<String>(); | 1657 return Local<String>(); |
1674 } | 1658 } |
1675 } | 1659 } |
1676 | 1660 |
1677 | 1661 |
1678 MaybeLocal<Value> Script::Run(Local<Context> context) { | 1662 MaybeLocal<Value> Script::Run(Local<Context> context) { |
1679 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) | 1663 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Script::Run()", Value) |
1680 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1664 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
1681 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 1665 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
1682 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); | 1666 auto fun = i::Handle<i::JSFunction>::cast(Utils::OpenHandle(this)); |
1683 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate); | 1667 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript( | 1946 ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript( |
1963 Isolate* v8_isolate, StreamedSource* source, CompileOptions options) { | 1947 Isolate* v8_isolate, StreamedSource* source, CompileOptions options) { |
1964 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1948 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
1965 return new i::BackgroundParsingTask(source->impl(), options, | 1949 return new i::BackgroundParsingTask(source->impl(), options, |
1966 i::FLAG_stack_size, isolate); | 1950 i::FLAG_stack_size, isolate); |
1967 } | 1951 } |
1968 | 1952 |
1969 | 1953 |
1970 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, | 1954 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, |
1971 StreamedSource* v8_source, | 1955 StreamedSource* v8_source, |
1972 Handle<String> full_source_string, | 1956 Local<String> full_source_string, |
1973 const ScriptOrigin& origin) { | 1957 const ScriptOrigin& origin) { |
1974 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); | 1958 PREPARE_FOR_EXECUTION(context, "v8::ScriptCompiler::Compile()", Script); |
1975 i::StreamedSource* source = v8_source->impl(); | 1959 i::StreamedSource* source = v8_source->impl(); |
1976 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); | 1960 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); |
1977 i::Handle<i::Script> script = isolate->factory()->NewScript(str); | 1961 i::Handle<i::Script> script = isolate->factory()->NewScript(str); |
1978 if (!origin.ResourceName().IsEmpty()) { | 1962 if (!origin.ResourceName().IsEmpty()) { |
1979 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 1963 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
1980 } | 1964 } |
1981 if (!origin.ResourceLineOffset().IsEmpty()) { | 1965 if (!origin.ResourceLineOffset().IsEmpty()) { |
1982 script->set_line_offset(i::Smi::FromInt( | 1966 script->set_line_offset(i::Smi::FromInt( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result); | 2000 Local<UnboundScript> generic = ToApiHandle<UnboundScript>(result); |
2017 if (generic.IsEmpty()) return Local<Script>(); | 2001 if (generic.IsEmpty()) return Local<Script>(); |
2018 Local<Script> bound = generic->BindToCurrentContext(); | 2002 Local<Script> bound = generic->BindToCurrentContext(); |
2019 if (bound.IsEmpty()) return Local<Script>(); | 2003 if (bound.IsEmpty()) return Local<Script>(); |
2020 RETURN_ESCAPED(bound); | 2004 RETURN_ESCAPED(bound); |
2021 } | 2005 } |
2022 | 2006 |
2023 | 2007 |
2024 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, | 2008 Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, |
2025 StreamedSource* v8_source, | 2009 StreamedSource* v8_source, |
2026 Handle<String> full_source_string, | 2010 Local<String> full_source_string, |
2027 const ScriptOrigin& origin) { | 2011 const ScriptOrigin& origin) { |
2028 auto context = v8_isolate->GetCurrentContext(); | 2012 auto context = v8_isolate->GetCurrentContext(); |
2029 RETURN_TO_LOCAL_UNCHECKED( | 2013 RETURN_TO_LOCAL_UNCHECKED( |
2030 Compile(context, v8_source, full_source_string, origin), Script); | 2014 Compile(context, v8_source, full_source_string, origin), Script); |
2031 } | 2015 } |
2032 | 2016 |
2033 | 2017 |
2034 uint32_t ScriptCompiler::CachedDataVersionTag() { | 2018 uint32_t ScriptCompiler::CachedDataVersionTag() { |
2035 return static_cast<uint32_t>(base::hash_combine( | 2019 return static_cast<uint32_t>(base::hash_combine( |
2036 internal::Version::Hash(), internal::FlagList::Hash(), | 2020 internal::Version::Hash(), internal::FlagList::Hash(), |
2037 static_cast<uint32_t>(internal::CpuFeatures::SupportedFeatures()))); | 2021 static_cast<uint32_t>(internal::CpuFeatures::SupportedFeatures()))); |
2038 } | 2022 } |
2039 | 2023 |
2040 | 2024 |
2041 MaybeLocal<Script> Script::Compile(Local<Context> context, | 2025 MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source, |
2042 Handle<String> source, | |
2043 ScriptOrigin* origin) { | 2026 ScriptOrigin* origin) { |
2044 if (origin) { | 2027 if (origin) { |
2045 ScriptCompiler::Source script_source(source, *origin); | 2028 ScriptCompiler::Source script_source(source, *origin); |
2046 return ScriptCompiler::Compile(context, &script_source); | 2029 return ScriptCompiler::Compile(context, &script_source); |
2047 } | 2030 } |
2048 ScriptCompiler::Source script_source(source); | 2031 ScriptCompiler::Source script_source(source); |
2049 return ScriptCompiler::Compile(context, &script_source); | 2032 return ScriptCompiler::Compile(context, &script_source); |
2050 } | 2033 } |
2051 | 2034 |
2052 | 2035 |
2053 Local<Script> Script::Compile(v8::Handle<String> source, | 2036 Local<Script> Script::Compile(v8::Local<String> source, |
2054 v8::ScriptOrigin* origin) { | 2037 v8::ScriptOrigin* origin) { |
2055 auto str = Utils::OpenHandle(*source); | 2038 auto str = Utils::OpenHandle(*source); |
2056 auto context = ContextFromHeapObject(str); | 2039 auto context = ContextFromHeapObject(str); |
2057 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, origin), Script); | 2040 RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, origin), Script); |
2058 } | 2041 } |
2059 | 2042 |
2060 | 2043 |
2061 Local<Script> Script::Compile(v8::Handle<String> source, | 2044 Local<Script> Script::Compile(v8::Local<String> source, |
2062 v8::Handle<String> file_name) { | 2045 v8::Local<String> file_name) { |
2063 auto str = Utils::OpenHandle(*source); | 2046 auto str = Utils::OpenHandle(*source); |
2064 auto context = ContextFromHeapObject(str); | 2047 auto context = ContextFromHeapObject(str); |
2065 ScriptOrigin origin(file_name); | 2048 ScriptOrigin origin(file_name); |
2066 return Compile(context, source, &origin).FromMaybe(Local<Script>()); | 2049 return Compile(context, source, &origin).FromMaybe(Local<Script>()); |
2067 } | 2050 } |
2068 | 2051 |
2069 | 2052 |
2070 // --- E x c e p t i o n s --- | 2053 // --- E x c e p t i o n s --- |
2071 | 2054 |
2072 | 2055 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 bool v8::TryCatch::CanContinue() const { | 2125 bool v8::TryCatch::CanContinue() const { |
2143 return can_continue_; | 2126 return can_continue_; |
2144 } | 2127 } |
2145 | 2128 |
2146 | 2129 |
2147 bool v8::TryCatch::HasTerminated() const { | 2130 bool v8::TryCatch::HasTerminated() const { |
2148 return has_terminated_; | 2131 return has_terminated_; |
2149 } | 2132 } |
2150 | 2133 |
2151 | 2134 |
2152 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { | 2135 v8::Local<v8::Value> v8::TryCatch::ReThrow() { |
2153 if (!HasCaught()) return v8::Local<v8::Value>(); | 2136 if (!HasCaught()) return v8::Local<v8::Value>(); |
2154 rethrow_ = true; | 2137 rethrow_ = true; |
2155 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_)); | 2138 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate_)); |
2156 } | 2139 } |
2157 | 2140 |
2158 | 2141 |
2159 v8::Local<Value> v8::TryCatch::Exception() const { | 2142 v8::Local<Value> v8::TryCatch::Exception() const { |
2160 if (HasCaught()) { | 2143 if (HasCaught()) { |
2161 // Check for out of memory exception. | 2144 // Check for out of memory exception. |
2162 i::Object* exception = reinterpret_cast<i::Object*>(exception_); | 2145 i::Object* exception = reinterpret_cast<i::Object*>(exception_); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 ScriptOrigin Message::GetScriptOrigin() const { | 2231 ScriptOrigin Message::GetScriptOrigin() const { |
2249 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2232 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2250 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2233 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2251 auto script_wraper = i::Handle<i::Object>(message->script(), isolate); | 2234 auto script_wraper = i::Handle<i::Object>(message->script(), isolate); |
2252 auto script_value = i::Handle<i::JSValue>::cast(script_wraper); | 2235 auto script_value = i::Handle<i::JSValue>::cast(script_wraper); |
2253 i::Handle<i::Script> script(i::Script::cast(script_value->value())); | 2236 i::Handle<i::Script> script(i::Script::cast(script_value->value())); |
2254 return GetScriptOriginForScript(isolate, script); | 2237 return GetScriptOriginForScript(isolate, script); |
2255 } | 2238 } |
2256 | 2239 |
2257 | 2240 |
2258 v8::Handle<Value> Message::GetScriptResourceName() const { | 2241 v8::Local<Value> Message::GetScriptResourceName() const { |
2259 return GetScriptOrigin().ResourceName(); | 2242 return GetScriptOrigin().ResourceName(); |
2260 } | 2243 } |
2261 | 2244 |
2262 | 2245 |
2263 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 2246 v8::Local<v8::StackTrace> Message::GetStackTrace() const { |
2264 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2247 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2265 ENTER_V8(isolate); | 2248 ENTER_V8(isolate); |
2266 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2249 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2267 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2250 auto message = i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2268 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2251 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
2269 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 2252 if (!stackFramesObj->IsJSArray()) return v8::Local<v8::StackTrace>(); |
2270 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); | 2253 auto stackTrace = i::Handle<i::JSArray>::cast(stackFramesObj); |
2271 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); | 2254 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); |
2272 } | 2255 } |
2273 | 2256 |
2274 | 2257 |
2275 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( | 2258 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
2276 i::Isolate* isolate, const char* name, i::Handle<i::Object> recv, int argc, | 2259 i::Isolate* isolate, const char* name, i::Handle<i::Object> recv, int argc, |
2277 i::Handle<i::Object> argv[]) { | 2260 i::Handle<i::Object> argv[]) { |
2278 i::Handle<i::Object> object_fun = | 2261 i::Handle<i::Object> object_fun = |
2279 i::Object::GetProperty( | 2262 i::Object::GetProperty( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2528 | 2511 |
2529 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) { | 2512 Local<NativeWeakMap> NativeWeakMap::New(Isolate* v8_isolate) { |
2530 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 2513 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
2531 ENTER_V8(isolate); | 2514 ENTER_V8(isolate); |
2532 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); | 2515 i::Handle<i::JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap(); |
2533 i::Runtime::WeakCollectionInitialize(isolate, weakmap); | 2516 i::Runtime::WeakCollectionInitialize(isolate, weakmap); |
2534 return Utils::NativeWeakMapToLocal(weakmap); | 2517 return Utils::NativeWeakMapToLocal(weakmap); |
2535 } | 2518 } |
2536 | 2519 |
2537 | 2520 |
2538 void NativeWeakMap::Set(Handle<Value> v8_key, Handle<Value> v8_value) { | 2521 void NativeWeakMap::Set(Local<Value> v8_key, Local<Value> v8_value) { |
2539 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); | 2522 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); |
2540 i::Isolate* isolate = weak_collection->GetIsolate(); | 2523 i::Isolate* isolate = weak_collection->GetIsolate(); |
2541 ENTER_V8(isolate); | 2524 ENTER_V8(isolate); |
2542 i::HandleScope scope(isolate); | 2525 i::HandleScope scope(isolate); |
2543 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); | 2526 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); |
2544 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value); | 2527 i::Handle<i::Object> value = Utils::OpenHandle(*v8_value); |
2545 if (!key->IsJSReceiver() && !key->IsSymbol()) { | 2528 if (!key->IsJSReceiver() && !key->IsSymbol()) { |
2546 DCHECK(false); | 2529 DCHECK(false); |
2547 return; | 2530 return; |
2548 } | 2531 } |
2549 i::Handle<i::ObjectHashTable> table( | 2532 i::Handle<i::ObjectHashTable> table( |
2550 i::ObjectHashTable::cast(weak_collection->table())); | 2533 i::ObjectHashTable::cast(weak_collection->table())); |
2551 if (!table->IsKey(*key)) { | 2534 if (!table->IsKey(*key)) { |
2552 DCHECK(false); | 2535 DCHECK(false); |
2553 return; | 2536 return; |
2554 } | 2537 } |
2555 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); | 2538 int32_t hash = i::Object::GetOrCreateHash(isolate, key)->value(); |
2556 i::Runtime::WeakCollectionSet(weak_collection, key, value, hash); | 2539 i::Runtime::WeakCollectionSet(weak_collection, key, value, hash); |
2557 } | 2540 } |
2558 | 2541 |
2559 | 2542 |
2560 Local<Value> NativeWeakMap::Get(Handle<Value> v8_key) { | 2543 Local<Value> NativeWeakMap::Get(Local<Value> v8_key) { |
2561 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); | 2544 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); |
2562 i::Isolate* isolate = weak_collection->GetIsolate(); | 2545 i::Isolate* isolate = weak_collection->GetIsolate(); |
2563 ENTER_V8(isolate); | 2546 ENTER_V8(isolate); |
2564 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); | 2547 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); |
2565 if (!key->IsJSReceiver() && !key->IsSymbol()) { | 2548 if (!key->IsJSReceiver() && !key->IsSymbol()) { |
2566 DCHECK(false); | 2549 DCHECK(false); |
2567 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 2550 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
2568 } | 2551 } |
2569 i::Handle<i::ObjectHashTable> table( | 2552 i::Handle<i::ObjectHashTable> table( |
2570 i::ObjectHashTable::cast(weak_collection->table())); | 2553 i::ObjectHashTable::cast(weak_collection->table())); |
2571 if (!table->IsKey(*key)) { | 2554 if (!table->IsKey(*key)) { |
2572 DCHECK(false); | 2555 DCHECK(false); |
2573 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 2556 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
2574 } | 2557 } |
2575 i::Handle<i::Object> lookup(table->Lookup(key), isolate); | 2558 i::Handle<i::Object> lookup(table->Lookup(key), isolate); |
2576 if (lookup->IsTheHole()) | 2559 if (lookup->IsTheHole()) |
2577 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 2560 return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
2578 return Utils::ToLocal(lookup); | 2561 return Utils::ToLocal(lookup); |
2579 } | 2562 } |
2580 | 2563 |
2581 | 2564 |
2582 bool NativeWeakMap::Has(Handle<Value> v8_key) { | 2565 bool NativeWeakMap::Has(Local<Value> v8_key) { |
2583 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); | 2566 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); |
2584 i::Isolate* isolate = weak_collection->GetIsolate(); | 2567 i::Isolate* isolate = weak_collection->GetIsolate(); |
2585 ENTER_V8(isolate); | 2568 ENTER_V8(isolate); |
2586 i::HandleScope scope(isolate); | 2569 i::HandleScope scope(isolate); |
2587 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); | 2570 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); |
2588 if (!key->IsJSReceiver() && !key->IsSymbol()) { | 2571 if (!key->IsJSReceiver() && !key->IsSymbol()) { |
2589 DCHECK(false); | 2572 DCHECK(false); |
2590 return false; | 2573 return false; |
2591 } | 2574 } |
2592 i::Handle<i::ObjectHashTable> table( | 2575 i::Handle<i::ObjectHashTable> table( |
2593 i::ObjectHashTable::cast(weak_collection->table())); | 2576 i::ObjectHashTable::cast(weak_collection->table())); |
2594 if (!table->IsKey(*key)) { | 2577 if (!table->IsKey(*key)) { |
2595 DCHECK(false); | 2578 DCHECK(false); |
2596 return false; | 2579 return false; |
2597 } | 2580 } |
2598 i::Handle<i::Object> lookup(table->Lookup(key), isolate); | 2581 i::Handle<i::Object> lookup(table->Lookup(key), isolate); |
2599 return !lookup->IsTheHole(); | 2582 return !lookup->IsTheHole(); |
2600 } | 2583 } |
2601 | 2584 |
2602 | 2585 |
2603 bool NativeWeakMap::Delete(Handle<Value> v8_key) { | 2586 bool NativeWeakMap::Delete(Local<Value> v8_key) { |
2604 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); | 2587 i::Handle<i::JSWeakMap> weak_collection = Utils::OpenHandle(this); |
2605 i::Isolate* isolate = weak_collection->GetIsolate(); | 2588 i::Isolate* isolate = weak_collection->GetIsolate(); |
2606 ENTER_V8(isolate); | 2589 ENTER_V8(isolate); |
2607 i::HandleScope scope(isolate); | 2590 i::HandleScope scope(isolate); |
2608 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); | 2591 i::Handle<i::Object> key = Utils::OpenHandle(*v8_key); |
2609 if (!key->IsJSReceiver() && !key->IsSymbol()) { | 2592 if (!key->IsJSReceiver() && !key->IsSymbol()) { |
2610 DCHECK(false); | 2593 DCHECK(false); |
2611 return false; | 2594 return false; |
2612 } | 2595 } |
2613 i::Handle<i::ObjectHashTable> table( | 2596 i::Handle<i::ObjectHashTable> table( |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3370 auto self = Utils::OpenHandle(this); | 3353 auto self = Utils::OpenHandle(this); |
3371 if (self->IsSmi()) { | 3354 if (self->IsSmi()) { |
3372 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); | 3355 if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self); |
3373 return Local<Uint32>(); | 3356 return Local<Uint32>(); |
3374 } | 3357 } |
3375 auto context = ContextFromHeapObject(self); | 3358 auto context = ContextFromHeapObject(self); |
3376 RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32); | 3359 RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32); |
3377 } | 3360 } |
3378 | 3361 |
3379 | 3362 |
3380 Maybe<bool> Value::Equals(Local<Context> context, Handle<Value> that) const { | 3363 Maybe<bool> Value::Equals(Local<Context> context, Local<Value> that) const { |
3381 auto self = Utils::OpenHandle(this); | 3364 auto self = Utils::OpenHandle(this); |
3382 auto other = Utils::OpenHandle(*that); | 3365 auto other = Utils::OpenHandle(*that); |
3383 if (self->IsSmi() && other->IsSmi()) { | 3366 if (self->IsSmi() && other->IsSmi()) { |
3384 return Just(self->Number() == other->Number()); | 3367 return Just(self->Number() == other->Number()); |
3385 } | 3368 } |
3386 if (self->IsJSObject() && other->IsJSObject()) { | 3369 if (self->IsJSObject() && other->IsJSObject()) { |
3387 return Just(*self == *other); | 3370 return Just(*self == *other); |
3388 } | 3371 } |
3389 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Value::Equals()", bool); | 3372 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Value::Equals()", bool); |
3390 i::Handle<i::Object> args[] = { other }; | 3373 i::Handle<i::Object> args[] = { other }; |
3391 i::Handle<i::Object> result; | 3374 i::Handle<i::Object> result; |
3392 has_pending_exception = | 3375 has_pending_exception = |
3393 !CallV8HeapFunction(isolate, "EQUALS", self, arraysize(args), args) | 3376 !CallV8HeapFunction(isolate, "EQUALS", self, arraysize(args), args) |
3394 .ToHandle(&result); | 3377 .ToHandle(&result); |
3395 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3378 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3396 return Just(*result == i::Smi::FromInt(i::EQUAL)); | 3379 return Just(*result == i::Smi::FromInt(i::EQUAL)); |
3397 } | 3380 } |
3398 | 3381 |
3399 | 3382 |
3400 bool Value::Equals(Handle<Value> that) const { | 3383 bool Value::Equals(Local<Value> that) const { |
3401 auto self = Utils::OpenHandle(this); | 3384 auto self = Utils::OpenHandle(this); |
3402 auto other = Utils::OpenHandle(*that); | 3385 auto other = Utils::OpenHandle(*that); |
3403 if (self->IsSmi() && other->IsSmi()) { | 3386 if (self->IsSmi() && other->IsSmi()) { |
3404 return self->Number() == other->Number(); | 3387 return self->Number() == other->Number(); |
3405 } | 3388 } |
3406 if (self->IsJSObject() && other->IsJSObject()) { | 3389 if (self->IsJSObject() && other->IsJSObject()) { |
3407 return *self == *other; | 3390 return *self == *other; |
3408 } | 3391 } |
3409 auto heap_object = self->IsSmi() ? other : self; | 3392 auto heap_object = self->IsSmi() ? other : self; |
3410 auto context = ContextFromHeapObject(heap_object); | 3393 auto context = ContextFromHeapObject(heap_object); |
3411 return Equals(context, that).FromMaybe(false); | 3394 return Equals(context, that).FromMaybe(false); |
3412 } | 3395 } |
3413 | 3396 |
3414 | 3397 |
3415 bool Value::StrictEquals(Handle<Value> that) const { | 3398 bool Value::StrictEquals(Local<Value> that) const { |
3416 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 3399 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
3417 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 3400 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
3418 if (obj->IsSmi()) { | 3401 if (obj->IsSmi()) { |
3419 return other->IsNumber() && obj->Number() == other->Number(); | 3402 return other->IsNumber() && obj->Number() == other->Number(); |
3420 } | 3403 } |
3421 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 3404 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
3422 LOG_API(isolate, "StrictEquals"); | 3405 LOG_API(isolate, "StrictEquals"); |
3423 // Must check HeapNumber first, since NaN !== NaN. | 3406 // Must check HeapNumber first, since NaN !== NaN. |
3424 if (obj->IsHeapNumber()) { | 3407 if (obj->IsHeapNumber()) { |
3425 if (!other->IsNumber()) return false; | 3408 if (!other->IsNumber()) return false; |
(...skipping 10 matching lines...) Expand all Loading... |
3436 i::String::Equals(i::Handle<i::String>::cast(obj), | 3419 i::String::Equals(i::Handle<i::String>::cast(obj), |
3437 i::Handle<i::String>::cast(other)); | 3420 i::Handle<i::String>::cast(other)); |
3438 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { | 3421 } else if (obj->IsUndefined() || obj->IsUndetectableObject()) { |
3439 return other->IsUndefined() || other->IsUndetectableObject(); | 3422 return other->IsUndefined() || other->IsUndetectableObject(); |
3440 } else { | 3423 } else { |
3441 return false; | 3424 return false; |
3442 } | 3425 } |
3443 } | 3426 } |
3444 | 3427 |
3445 | 3428 |
3446 bool Value::SameValue(Handle<Value> that) const { | 3429 bool Value::SameValue(Local<Value> that) const { |
3447 auto self = Utils::OpenHandle(this); | 3430 auto self = Utils::OpenHandle(this); |
3448 auto other = Utils::OpenHandle(*that); | 3431 auto other = Utils::OpenHandle(*that); |
3449 return self->SameValue(*other); | 3432 return self->SameValue(*other); |
3450 } | 3433 } |
3451 | 3434 |
3452 | 3435 |
3453 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, | 3436 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, |
3454 v8::Local<Value> key, v8::Local<Value> value) { | 3437 v8::Local<Value> key, v8::Local<Value> value) { |
3455 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3438 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); |
3456 auto self = Utils::OpenHandle(this); | 3439 auto self = Utils::OpenHandle(this); |
3457 auto key_obj = Utils::OpenHandle(*key); | 3440 auto key_obj = Utils::OpenHandle(*key); |
3458 auto value_obj = Utils::OpenHandle(*value); | 3441 auto value_obj = Utils::OpenHandle(*value); |
3459 has_pending_exception = | 3442 has_pending_exception = |
3460 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, | 3443 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj, |
3461 i::SLOPPY).is_null(); | 3444 i::SLOPPY).is_null(); |
3462 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3445 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3463 return Just(true); | 3446 return Just(true); |
3464 } | 3447 } |
3465 | 3448 |
3466 | 3449 |
3467 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value) { | 3450 bool v8::Object::Set(v8::Local<Value> key, v8::Local<Value> value) { |
3468 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3451 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3469 return Set(context, key, value).FromMaybe(false); | 3452 return Set(context, key, value).FromMaybe(false); |
3470 } | 3453 } |
3471 | 3454 |
3472 | 3455 |
3473 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, | 3456 Maybe<bool> v8::Object::Set(v8::Local<v8::Context> context, uint32_t index, |
3474 v8::Local<Value> value) { | 3457 v8::Local<Value> value) { |
3475 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); | 3458 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Set()", bool); |
3476 auto self = Utils::OpenHandle(this); | 3459 auto self = Utils::OpenHandle(this); |
3477 auto value_obj = Utils::OpenHandle(*value); | 3460 auto value_obj = Utils::OpenHandle(*value); |
3478 has_pending_exception = | 3461 has_pending_exception = |
3479 i::JSReceiver::SetElement(self, index, value_obj, i::SLOPPY).is_null(); | 3462 i::JSReceiver::SetElement(self, index, value_obj, i::SLOPPY).is_null(); |
3480 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3463 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3481 return Just(true); | 3464 return Just(true); |
3482 } | 3465 } |
3483 | 3466 |
3484 | 3467 |
3485 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { | 3468 bool v8::Object::Set(uint32_t index, v8::Local<Value> value) { |
3486 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3469 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3487 return Set(context, index, value).FromMaybe(false); | 3470 return Set(context, index, value).FromMaybe(false); |
3488 } | 3471 } |
3489 | 3472 |
3490 | 3473 |
3491 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, | 3474 Maybe<bool> v8::Object::CreateDataProperty(v8::Local<v8::Context> context, |
3492 v8::Local<Name> key, | 3475 v8::Local<Name> key, |
3493 v8::Local<Value> value) { | 3476 v8::Local<Value> value) { |
3494 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", | 3477 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::CreateDataProperty()", |
3495 bool); | 3478 bool); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3584 auto key_obj = Utils::OpenHandle(*key); | 3567 auto key_obj = Utils::OpenHandle(*key); |
3585 auto value_obj = Utils::OpenHandle(*value); | 3568 auto value_obj = Utils::OpenHandle(*value); |
3586 has_pending_exception = | 3569 has_pending_exception = |
3587 DefineObjectProperty(self, key_obj, value_obj, | 3570 DefineObjectProperty(self, key_obj, value_obj, |
3588 static_cast<PropertyAttributes>(attribs)).is_null(); | 3571 static_cast<PropertyAttributes>(attribs)).is_null(); |
3589 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3572 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3590 return Just(true); | 3573 return Just(true); |
3591 } | 3574 } |
3592 | 3575 |
3593 | 3576 |
3594 bool v8::Object::ForceSet(v8::Handle<Value> key, v8::Handle<Value> value, | 3577 bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value, |
3595 v8::PropertyAttribute attribs) { | 3578 v8::PropertyAttribute attribs) { |
3596 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3579 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3597 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), | 3580 PREPARE_FOR_EXECUTION_GENERIC(isolate, Local<Context>(), |
3598 "v8::Object::ForceSet", false, i::HandleScope, | 3581 "v8::Object::ForceSet", false, i::HandleScope, |
3599 false); | 3582 false); |
3600 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3583 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3601 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3584 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3602 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3585 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
3603 has_pending_exception = | 3586 has_pending_exception = |
3604 DefineObjectProperty(self, key_obj, value_obj, | 3587 DefineObjectProperty(self, key_obj, value_obj, |
3605 static_cast<PropertyAttributes>(attribs)).is_null(); | 3588 static_cast<PropertyAttributes>(attribs)).is_null(); |
3606 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3589 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
3607 return true; | 3590 return true; |
3608 } | 3591 } |
3609 | 3592 |
3610 | 3593 |
3611 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3594 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
3612 Local<Value> key) { | 3595 Local<Value> key) { |
3613 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3596 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); |
3614 auto self = Utils::OpenHandle(this); | 3597 auto self = Utils::OpenHandle(this); |
3615 auto key_obj = Utils::OpenHandle(*key); | 3598 auto key_obj = Utils::OpenHandle(*key); |
3616 i::Handle<i::Object> result; | 3599 i::Handle<i::Object> result; |
3617 has_pending_exception = | 3600 has_pending_exception = |
3618 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); | 3601 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); |
3619 RETURN_ON_FAILED_EXECUTION(Value); | 3602 RETURN_ON_FAILED_EXECUTION(Value); |
3620 RETURN_ESCAPED(Utils::ToLocal(result)); | 3603 RETURN_ESCAPED(Utils::ToLocal(result)); |
3621 } | 3604 } |
3622 | 3605 |
3623 | 3606 |
3624 Local<Value> v8::Object::Get(v8::Handle<Value> key) { | 3607 Local<Value> v8::Object::Get(v8::Local<Value> key) { |
3625 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3608 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3626 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); | 3609 RETURN_TO_LOCAL_UNCHECKED(Get(context, key), Value); |
3627 } | 3610 } |
3628 | 3611 |
3629 | 3612 |
3630 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { | 3613 MaybeLocal<Value> v8::Object::Get(Local<Context> context, uint32_t index) { |
3631 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3614 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); |
3632 auto self = Utils::OpenHandle(this); | 3615 auto self = Utils::OpenHandle(this); |
3633 i::Handle<i::Object> result; | 3616 i::Handle<i::Object> result; |
3634 has_pending_exception = | 3617 has_pending_exception = |
(...skipping 24 matching lines...) Expand all Loading... |
3659 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); | 3642 auto result = i::JSReceiver::GetPropertyAttributes(self, key_name); |
3660 has_pending_exception = result.IsNothing(); | 3643 has_pending_exception = result.IsNothing(); |
3661 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 3644 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
3662 if (result.FromJust() == ABSENT) { | 3645 if (result.FromJust() == ABSENT) { |
3663 return Just(static_cast<PropertyAttribute>(NONE)); | 3646 return Just(static_cast<PropertyAttribute>(NONE)); |
3664 } | 3647 } |
3665 return Just(static_cast<PropertyAttribute>(result.FromJust())); | 3648 return Just(static_cast<PropertyAttribute>(result.FromJust())); |
3666 } | 3649 } |
3667 | 3650 |
3668 | 3651 |
3669 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { | 3652 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) { |
3670 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3653 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3671 return GetPropertyAttributes(context, key) | 3654 return GetPropertyAttributes(context, key) |
3672 .FromMaybe(static_cast<PropertyAttribute>(NONE)); | 3655 .FromMaybe(static_cast<PropertyAttribute>(NONE)); |
3673 } | 3656 } |
3674 | 3657 |
3675 | 3658 |
3676 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, | 3659 MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context, |
3677 Local<String> key) { | 3660 Local<String> key) { |
3678 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", | 3661 PREPARE_FOR_EXECUTION(context, "v8::Object::GetOwnPropertyDescriptor()", |
3679 Value); | 3662 Value); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3712 // We do not allow exceptions thrown while setting the prototype | 3695 // We do not allow exceptions thrown while setting the prototype |
3713 // to propagate outside. | 3696 // to propagate outside. |
3714 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 3697 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
3715 auto result = i::JSObject::SetPrototype(self, value_obj, false); | 3698 auto result = i::JSObject::SetPrototype(self, value_obj, false); |
3716 has_pending_exception = result.is_null(); | 3699 has_pending_exception = result.is_null(); |
3717 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3700 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3718 return Just(true); | 3701 return Just(true); |
3719 } | 3702 } |
3720 | 3703 |
3721 | 3704 |
3722 bool v8::Object::SetPrototype(Handle<Value> value) { | 3705 bool v8::Object::SetPrototype(Local<Value> value) { |
3723 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3706 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3724 return SetPrototype(context, value).FromMaybe(false); | 3707 return SetPrototype(context, value).FromMaybe(false); |
3725 } | 3708 } |
3726 | 3709 |
3727 | 3710 |
3728 Local<Object> v8::Object::FindInstanceInPrototypeChain( | 3711 Local<Object> v8::Object::FindInstanceInPrototypeChain( |
3729 v8::Handle<FunctionTemplate> tmpl) { | 3712 v8::Local<FunctionTemplate> tmpl) { |
3730 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 3713 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
3731 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), | 3714 i::PrototypeIterator iter(isolate, *Utils::OpenHandle(this), |
3732 i::PrototypeIterator::START_AT_RECEIVER); | 3715 i::PrototypeIterator::START_AT_RECEIVER); |
3733 auto tmpl_info = *Utils::OpenHandle(*tmpl); | 3716 auto tmpl_info = *Utils::OpenHandle(*tmpl); |
3734 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { | 3717 while (!tmpl_info->IsTemplateFor(iter.GetCurrent())) { |
3735 iter.Advance(); | 3718 iter.Advance(); |
3736 if (iter.IsAtEnd()) { | 3719 if (iter.IsAtEnd()) { |
3737 return Local<Object>(); | 3720 return Local<Object>(); |
3738 } | 3721 } |
3739 } | 3722 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3865 auto key_obj = Utils::OpenHandle(*key); | 3848 auto key_obj = Utils::OpenHandle(*key); |
3866 i::Handle<i::Object> obj; | 3849 i::Handle<i::Object> obj; |
3867 has_pending_exception = | 3850 has_pending_exception = |
3868 !i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY) | 3851 !i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY) |
3869 .ToHandle(&obj); | 3852 .ToHandle(&obj); |
3870 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3853 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3871 return Just(obj->IsTrue()); | 3854 return Just(obj->IsTrue()); |
3872 } | 3855 } |
3873 | 3856 |
3874 | 3857 |
3875 bool v8::Object::Delete(v8::Handle<Value> key) { | 3858 bool v8::Object::Delete(v8::Local<Value> key) { |
3876 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3859 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3877 return Delete(context, key).FromMaybe(false); | 3860 return Delete(context, key).FromMaybe(false); |
3878 } | 3861 } |
3879 | 3862 |
3880 | 3863 |
3881 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { | 3864 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { |
3882 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 3865 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); |
3883 auto self = Utils::OpenHandle(this); | 3866 auto self = Utils::OpenHandle(this); |
3884 auto key_obj = Utils::OpenHandle(*key); | 3867 auto key_obj = Utils::OpenHandle(*key); |
3885 Maybe<bool> maybe = Nothing<bool>(); | 3868 Maybe<bool> maybe = Nothing<bool>(); |
3886 // Check if the given key is an array index. | 3869 // Check if the given key is an array index. |
3887 uint32_t index = 0; | 3870 uint32_t index = 0; |
3888 if (key_obj->ToArrayIndex(&index)) { | 3871 if (key_obj->ToArrayIndex(&index)) { |
3889 maybe = i::JSReceiver::HasElement(self, index); | 3872 maybe = i::JSReceiver::HasElement(self, index); |
3890 } else { | 3873 } else { |
3891 // Convert the key to a name - possibly by calling back into JavaScript. | 3874 // Convert the key to a name - possibly by calling back into JavaScript. |
3892 i::Handle<i::Name> name; | 3875 i::Handle<i::Name> name; |
3893 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { | 3876 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { |
3894 maybe = i::JSReceiver::HasProperty(self, name); | 3877 maybe = i::JSReceiver::HasProperty(self, name); |
3895 } | 3878 } |
3896 } | 3879 } |
3897 has_pending_exception = maybe.IsNothing(); | 3880 has_pending_exception = maybe.IsNothing(); |
3898 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3881 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3899 return maybe; | 3882 return maybe; |
3900 } | 3883 } |
3901 | 3884 |
3902 | 3885 |
3903 bool v8::Object::Has(v8::Handle<Value> key) { | 3886 bool v8::Object::Has(v8::Local<Value> key) { |
3904 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3887 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3905 return Has(context, key).FromMaybe(false); | 3888 return Has(context, key).FromMaybe(false); |
3906 } | 3889 } |
3907 | 3890 |
3908 | 3891 |
3909 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { | 3892 Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) { |
3910 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DeleteProperty()", | 3893 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::DeleteProperty()", |
3911 bool); | 3894 bool); |
3912 auto self = Utils::OpenHandle(this); | 3895 auto self = Utils::OpenHandle(this); |
3913 i::Handle<i::Object> obj; | 3896 i::Handle<i::Object> obj; |
(...skipping 26 matching lines...) Expand all Loading... |
3940 } | 3923 } |
3941 | 3924 |
3942 | 3925 |
3943 template <typename Getter, typename Setter, typename Data> | 3926 template <typename Getter, typename Setter, typename Data> |
3944 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, | 3927 static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* obj, |
3945 Local<Name> name, Getter getter, | 3928 Local<Name> name, Getter getter, |
3946 Setter setter, Data data, | 3929 Setter setter, Data data, |
3947 AccessControl settings, | 3930 AccessControl settings, |
3948 PropertyAttribute attributes) { | 3931 PropertyAttribute attributes) { |
3949 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); | 3932 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetAccessor()", bool); |
3950 v8::Handle<AccessorSignature> signature; | 3933 v8::Local<AccessorSignature> signature; |
3951 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, | 3934 auto info = MakeAccessorInfo(name, getter, setter, data, settings, attributes, |
3952 signature); | 3935 signature); |
3953 if (info.is_null()) return Nothing<bool>(); | 3936 if (info.is_null()) return Nothing<bool>(); |
3954 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); | 3937 bool fast = Utils::OpenHandle(obj)->HasFastProperties(); |
3955 i::Handle<i::Object> result; | 3938 i::Handle<i::Object> result; |
3956 has_pending_exception = | 3939 has_pending_exception = |
3957 !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); | 3940 !i::JSObject::SetAccessor(Utils::OpenHandle(obj), info).ToHandle(&result); |
3958 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3941 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
3959 if (result->IsUndefined()) return Nothing<bool>(); | 3942 if (result->IsUndefined()) return Nothing<bool>(); |
3960 if (fast) { | 3943 if (fast) { |
3961 i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); | 3944 i::JSObject::MigrateSlowToFast(Utils::OpenHandle(obj), 0, "APISetAccessor"); |
3962 } | 3945 } |
3963 return Just(true); | 3946 return Just(true); |
3964 } | 3947 } |
3965 | 3948 |
3966 | 3949 |
3967 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, | 3950 Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name, |
3968 AccessorNameGetterCallback getter, | 3951 AccessorNameGetterCallback getter, |
3969 AccessorNameSetterCallback setter, | 3952 AccessorNameSetterCallback setter, |
3970 MaybeLocal<Value> data, AccessControl settings, | 3953 MaybeLocal<Value> data, AccessControl settings, |
3971 PropertyAttribute attribute) { | 3954 PropertyAttribute attribute) { |
3972 return ObjectSetAccessor(context, this, name, getter, setter, | 3955 return ObjectSetAccessor(context, this, name, getter, setter, |
3973 data.FromMaybe(Local<Value>()), settings, attribute); | 3956 data.FromMaybe(Local<Value>()), settings, attribute); |
3974 } | 3957 } |
3975 | 3958 |
3976 | 3959 |
3977 bool Object::SetAccessor(Handle<String> name, | 3960 bool Object::SetAccessor(Local<String> name, AccessorGetterCallback getter, |
3978 AccessorGetterCallback getter, | 3961 AccessorSetterCallback setter, v8::Local<Value> data, |
3979 AccessorSetterCallback setter, | 3962 AccessControl settings, PropertyAttribute attributes) { |
3980 v8::Handle<Value> data, | |
3981 AccessControl settings, | |
3982 PropertyAttribute attributes) { | |
3983 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3963 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3984 return ObjectSetAccessor(context, this, name, getter, setter, data, settings, | 3964 return ObjectSetAccessor(context, this, name, getter, setter, data, settings, |
3985 attributes).FromMaybe(false); | 3965 attributes).FromMaybe(false); |
3986 } | 3966 } |
3987 | 3967 |
3988 | 3968 |
3989 bool Object::SetAccessor(Handle<Name> name, | 3969 bool Object::SetAccessor(Local<Name> name, AccessorNameGetterCallback getter, |
3990 AccessorNameGetterCallback getter, | |
3991 AccessorNameSetterCallback setter, | 3970 AccessorNameSetterCallback setter, |
3992 v8::Handle<Value> data, | 3971 v8::Local<Value> data, AccessControl settings, |
3993 AccessControl settings, | |
3994 PropertyAttribute attributes) { | 3972 PropertyAttribute attributes) { |
3995 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3973 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
3996 return ObjectSetAccessor(context, this, name, getter, setter, data, settings, | 3974 return ObjectSetAccessor(context, this, name, getter, setter, data, settings, |
3997 attributes).FromMaybe(false); | 3975 attributes).FromMaybe(false); |
3998 } | 3976 } |
3999 | 3977 |
4000 | 3978 |
4001 void Object::SetAccessorProperty(Local<Name> name, | 3979 void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter, |
4002 Local<Function> getter, | 3980 Local<Function> setter, |
4003 Handle<Function> setter, | |
4004 PropertyAttribute attribute, | 3981 PropertyAttribute attribute, |
4005 AccessControl settings) { | 3982 AccessControl settings) { |
4006 // TODO(verwaest): Remove |settings|. | 3983 // TODO(verwaest): Remove |settings|. |
4007 DCHECK_EQ(v8::DEFAULT, settings); | 3984 DCHECK_EQ(v8::DEFAULT, settings); |
4008 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3985 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4009 ENTER_V8(isolate); | 3986 ENTER_V8(isolate); |
4010 i::HandleScope scope(isolate); | 3987 i::HandleScope scope(isolate); |
4011 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); | 3988 i::Handle<i::Object> getter_i = v8::Utils::OpenHandle(*getter); |
4012 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); | 3989 i::Handle<i::Object> setter_i = v8::Utils::OpenHandle(*setter, true); |
4013 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); | 3990 if (setter_i.is_null()) setter_i = isolate->factory()->null_value(); |
(...skipping 11 matching lines...) Expand all Loading... |
4025 bool); | 4002 bool); |
4026 auto self = Utils::OpenHandle(this); | 4003 auto self = Utils::OpenHandle(this); |
4027 auto key_val = Utils::OpenHandle(*key); | 4004 auto key_val = Utils::OpenHandle(*key); |
4028 auto result = i::JSReceiver::HasOwnProperty(self, key_val); | 4005 auto result = i::JSReceiver::HasOwnProperty(self, key_val); |
4029 has_pending_exception = result.IsNothing(); | 4006 has_pending_exception = result.IsNothing(); |
4030 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4007 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4031 return result; | 4008 return result; |
4032 } | 4009 } |
4033 | 4010 |
4034 | 4011 |
4035 bool v8::Object::HasOwnProperty(Handle<String> key) { | 4012 bool v8::Object::HasOwnProperty(Local<String> key) { |
4036 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4013 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4037 return HasOwnProperty(context, key).FromMaybe(false); | 4014 return HasOwnProperty(context, key).FromMaybe(false); |
4038 } | 4015 } |
4039 | 4016 |
4040 | 4017 |
4041 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, | 4018 Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context, |
4042 Local<Name> key) { | 4019 Local<Name> key) { |
4043 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", | 4020 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::HasRealNamedProperty()", |
4044 bool); | 4021 bool); |
4045 auto self = Utils::OpenHandle(this); | 4022 auto self = Utils::OpenHandle(this); |
4046 auto key_val = Utils::OpenHandle(*key); | 4023 auto key_val = Utils::OpenHandle(*key); |
4047 auto result = i::JSObject::HasRealNamedProperty(self, key_val); | 4024 auto result = i::JSObject::HasRealNamedProperty(self, key_val); |
4048 has_pending_exception = result.IsNothing(); | 4025 has_pending_exception = result.IsNothing(); |
4049 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4026 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4050 return result; | 4027 return result; |
4051 } | 4028 } |
4052 | 4029 |
4053 | 4030 |
4054 bool v8::Object::HasRealNamedProperty(Handle<String> key) { | 4031 bool v8::Object::HasRealNamedProperty(Local<String> key) { |
4055 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4032 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4056 return HasRealNamedProperty(context, key).FromMaybe(false); | 4033 return HasRealNamedProperty(context, key).FromMaybe(false); |
4057 } | 4034 } |
4058 | 4035 |
4059 | 4036 |
4060 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, | 4037 Maybe<bool> v8::Object::HasRealIndexedProperty(Local<Context> context, |
4061 uint32_t index) { | 4038 uint32_t index) { |
4062 PREPARE_FOR_EXECUTION_PRIMITIVE(context, | 4039 PREPARE_FOR_EXECUTION_PRIMITIVE(context, |
4063 "v8::Object::HasRealIndexedProperty()", bool); | 4040 "v8::Object::HasRealIndexedProperty()", bool); |
4064 auto self = Utils::OpenHandle(this); | 4041 auto self = Utils::OpenHandle(this); |
(...skipping 16 matching lines...) Expand all Loading... |
4081 context, "v8::Object::HasRealNamedCallbackProperty()", bool); | 4058 context, "v8::Object::HasRealNamedCallbackProperty()", bool); |
4082 auto self = Utils::OpenHandle(this); | 4059 auto self = Utils::OpenHandle(this); |
4083 auto key_val = Utils::OpenHandle(*key); | 4060 auto key_val = Utils::OpenHandle(*key); |
4084 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); | 4061 auto result = i::JSObject::HasRealNamedCallbackProperty(self, key_val); |
4085 has_pending_exception = result.IsNothing(); | 4062 has_pending_exception = result.IsNothing(); |
4086 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 4063 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
4087 return result; | 4064 return result; |
4088 } | 4065 } |
4089 | 4066 |
4090 | 4067 |
4091 bool v8::Object::HasRealNamedCallbackProperty(Handle<String> key) { | 4068 bool v8::Object::HasRealNamedCallbackProperty(Local<String> key) { |
4092 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4069 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4093 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); | 4070 return HasRealNamedCallbackProperty(context, key).FromMaybe(false); |
4094 } | 4071 } |
4095 | 4072 |
4096 | 4073 |
4097 bool v8::Object::HasNamedLookupInterceptor() { | 4074 bool v8::Object::HasNamedLookupInterceptor() { |
4098 auto self = Utils::OpenHandle(this); | 4075 auto self = Utils::OpenHandle(this); |
4099 return self->HasNamedInterceptor(); | 4076 return self->HasNamedInterceptor(); |
4100 } | 4077 } |
4101 | 4078 |
(...skipping 18 matching lines...) Expand all Loading... |
4120 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4097 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4121 Local<Value> result; | 4098 Local<Value> result; |
4122 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4099 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
4123 RETURN_ON_FAILED_EXECUTION(Value); | 4100 RETURN_ON_FAILED_EXECUTION(Value); |
4124 if (!it.IsFound()) return MaybeLocal<Value>(); | 4101 if (!it.IsFound()) return MaybeLocal<Value>(); |
4125 RETURN_ESCAPED(result); | 4102 RETURN_ESCAPED(result); |
4126 } | 4103 } |
4127 | 4104 |
4128 | 4105 |
4129 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( | 4106 Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain( |
4130 Handle<String> key) { | 4107 Local<String> key) { |
4131 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4108 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4132 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), | 4109 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key), |
4133 Value); | 4110 Value); |
4134 } | 4111 } |
4135 | 4112 |
4136 | 4113 |
4137 Maybe<PropertyAttribute> | 4114 Maybe<PropertyAttribute> |
4138 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( | 4115 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain( |
4139 Local<Context> context, Local<Name> key) { | 4116 Local<Context> context, Local<Name> key) { |
4140 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4117 PREPARE_FOR_EXECUTION_PRIMITIVE( |
(...skipping 12 matching lines...) Expand all Loading... |
4153 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4130 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4154 if (result.FromJust() == ABSENT) { | 4131 if (result.FromJust() == ABSENT) { |
4155 return Just(static_cast<PropertyAttribute>(NONE)); | 4132 return Just(static_cast<PropertyAttribute>(NONE)); |
4156 } | 4133 } |
4157 return Just<PropertyAttribute>( | 4134 return Just<PropertyAttribute>( |
4158 static_cast<PropertyAttribute>(result.FromJust())); | 4135 static_cast<PropertyAttribute>(result.FromJust())); |
4159 } | 4136 } |
4160 | 4137 |
4161 | 4138 |
4162 Maybe<PropertyAttribute> | 4139 Maybe<PropertyAttribute> |
4163 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Handle<String> key) { | 4140 v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) { |
4164 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4141 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4165 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); | 4142 return GetRealNamedPropertyAttributesInPrototypeChain(context, key); |
4166 } | 4143 } |
4167 | 4144 |
4168 | 4145 |
4169 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, | 4146 MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context, |
4170 Local<Name> key) { | 4147 Local<Name> key) { |
4171 PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value); | 4148 PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value); |
4172 auto self = Utils::OpenHandle(this); | 4149 auto self = Utils::OpenHandle(this); |
4173 auto key_obj = Utils::OpenHandle(*key); | 4150 auto key_obj = Utils::OpenHandle(*key); |
4174 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4151 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4175 isolate, self, key_obj, | 4152 isolate, self, key_obj, |
4176 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4153 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4177 Local<Value> result; | 4154 Local<Value> result; |
4178 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); | 4155 has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result); |
4179 RETURN_ON_FAILED_EXECUTION(Value); | 4156 RETURN_ON_FAILED_EXECUTION(Value); |
4180 if (!it.IsFound()) return MaybeLocal<Value>(); | 4157 if (!it.IsFound()) return MaybeLocal<Value>(); |
4181 RETURN_ESCAPED(result); | 4158 RETURN_ESCAPED(result); |
4182 } | 4159 } |
4183 | 4160 |
4184 | 4161 |
4185 Local<Value> v8::Object::GetRealNamedProperty(Handle<String> key) { | 4162 Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) { |
4186 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4163 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4187 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); | 4164 RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value); |
4188 } | 4165 } |
4189 | 4166 |
4190 | 4167 |
4191 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4168 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
4192 Local<Context> context, Local<Name> key) { | 4169 Local<Context> context, Local<Name> key) { |
4193 PREPARE_FOR_EXECUTION_PRIMITIVE( | 4170 PREPARE_FOR_EXECUTION_PRIMITIVE( |
4194 context, "v8::Object::GetRealNamedPropertyAttributes()", | 4171 context, "v8::Object::GetRealNamedPropertyAttributes()", |
4195 PropertyAttribute); | 4172 PropertyAttribute); |
4196 auto self = Utils::OpenHandle(this); | 4173 auto self = Utils::OpenHandle(this); |
4197 auto key_obj = Utils::OpenHandle(*key); | 4174 auto key_obj = Utils::OpenHandle(*key); |
4198 i::LookupIterator it = i::LookupIterator::PropertyOrElement( | 4175 i::LookupIterator it = i::LookupIterator::PropertyOrElement( |
4199 isolate, self, key_obj, | 4176 isolate, self, key_obj, |
4200 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); | 4177 i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
4201 auto result = i::JSReceiver::GetPropertyAttributes(&it); | 4178 auto result = i::JSReceiver::GetPropertyAttributes(&it); |
4202 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); | 4179 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute); |
4203 if (!it.IsFound()) return Nothing<PropertyAttribute>(); | 4180 if (!it.IsFound()) return Nothing<PropertyAttribute>(); |
4204 if (result.FromJust() == ABSENT) { | 4181 if (result.FromJust() == ABSENT) { |
4205 return Just(static_cast<PropertyAttribute>(NONE)); | 4182 return Just(static_cast<PropertyAttribute>(NONE)); |
4206 } | 4183 } |
4207 return Just<PropertyAttribute>( | 4184 return Just<PropertyAttribute>( |
4208 static_cast<PropertyAttribute>(result.FromJust())); | 4185 static_cast<PropertyAttribute>(result.FromJust())); |
4209 } | 4186 } |
4210 | 4187 |
4211 | 4188 |
4212 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( | 4189 Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes( |
4213 Handle<String> key) { | 4190 Local<String> key) { |
4214 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4191 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4215 return GetRealNamedPropertyAttributes(context, key); | 4192 return GetRealNamedPropertyAttributes(context, key); |
4216 } | 4193 } |
4217 | 4194 |
4218 | 4195 |
4219 Local<v8::Object> v8::Object::Clone() { | 4196 Local<v8::Object> v8::Object::Clone() { |
4220 auto self = Utils::OpenHandle(this); | 4197 auto self = Utils::OpenHandle(this); |
4221 auto isolate = self->GetIsolate(); | 4198 auto isolate = self->GetIsolate(); |
4222 ENTER_V8(isolate); | 4199 ENTER_V8(isolate); |
4223 auto result = isolate->factory()->CopyJSObject(self); | 4200 auto result = isolate->factory()->CopyJSObject(self); |
(...skipping 10 matching lines...) Expand all Loading... |
4234 | 4211 |
4235 | 4212 |
4236 int v8::Object::GetIdentityHash() { | 4213 int v8::Object::GetIdentityHash() { |
4237 auto isolate = Utils::OpenHandle(this)->GetIsolate(); | 4214 auto isolate = Utils::OpenHandle(this)->GetIsolate(); |
4238 i::HandleScope scope(isolate); | 4215 i::HandleScope scope(isolate); |
4239 auto self = Utils::OpenHandle(this); | 4216 auto self = Utils::OpenHandle(this); |
4240 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); | 4217 return i::JSReceiver::GetOrCreateIdentityHash(self)->value(); |
4241 } | 4218 } |
4242 | 4219 |
4243 | 4220 |
4244 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 4221 bool v8::Object::SetHiddenValue(v8::Local<v8::String> key, |
4245 v8::Handle<v8::Value> value) { | 4222 v8::Local<v8::Value> value) { |
4246 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4223 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4247 if (value.IsEmpty()) return DeleteHiddenValue(key); | 4224 if (value.IsEmpty()) return DeleteHiddenValue(key); |
4248 ENTER_V8(isolate); | 4225 ENTER_V8(isolate); |
4249 i::HandleScope scope(isolate); | 4226 i::HandleScope scope(isolate); |
4250 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4227 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4251 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4228 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4252 i::Handle<i::String> key_string = | 4229 i::Handle<i::String> key_string = |
4253 isolate->factory()->InternalizeString(key_obj); | 4230 isolate->factory()->InternalizeString(key_obj); |
4254 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 4231 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
4255 i::Handle<i::Object> result = | 4232 i::Handle<i::Object> result = |
4256 i::JSObject::SetHiddenProperty(self, key_string, value_obj); | 4233 i::JSObject::SetHiddenProperty(self, key_string, value_obj); |
4257 return *result == *self; | 4234 return *result == *self; |
4258 } | 4235 } |
4259 | 4236 |
4260 | 4237 |
4261 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { | 4238 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Local<v8::String> key) { |
4262 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4239 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4263 ENTER_V8(isolate); | 4240 ENTER_V8(isolate); |
4264 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4241 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4265 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4242 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4266 i::Handle<i::String> key_string = | 4243 i::Handle<i::String> key_string = |
4267 isolate->factory()->InternalizeString(key_obj); | 4244 isolate->factory()->InternalizeString(key_obj); |
4268 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); | 4245 i::Handle<i::Object> result(self->GetHiddenProperty(key_string), isolate); |
4269 if (result->IsTheHole()) return v8::Local<v8::Value>(); | 4246 if (result->IsTheHole()) return v8::Local<v8::Value>(); |
4270 return Utils::ToLocal(result); | 4247 return Utils::ToLocal(result); |
4271 } | 4248 } |
4272 | 4249 |
4273 | 4250 |
4274 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { | 4251 bool v8::Object::DeleteHiddenValue(v8::Local<v8::String> key) { |
4275 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4252 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4276 ENTER_V8(isolate); | 4253 ENTER_V8(isolate); |
4277 i::HandleScope scope(isolate); | 4254 i::HandleScope scope(isolate); |
4278 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 4255 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
4279 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); | 4256 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); |
4280 i::Handle<i::String> key_string = | 4257 i::Handle<i::String> key_string = |
4281 isolate->factory()->InternalizeString(key_obj); | 4258 isolate->factory()->InternalizeString(key_obj); |
4282 i::JSObject::DeleteHiddenProperty(self, key_string); | 4259 i::JSObject::DeleteHiddenProperty(self, key_string); |
4283 return true; | 4260 return true; |
4284 } | 4261 } |
4285 | 4262 |
4286 | 4263 |
4287 bool v8::Object::IsCallable() { | 4264 bool v8::Object::IsCallable() { |
4288 auto self = Utils::OpenHandle(this); | 4265 auto self = Utils::OpenHandle(this); |
4289 return self->IsCallable(); | 4266 return self->IsCallable(); |
4290 } | 4267 } |
4291 | 4268 |
4292 | 4269 |
4293 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, | 4270 MaybeLocal<Value> Object::CallAsFunction(Local<Context> context, |
4294 Handle<Value> recv, int argc, | 4271 Local<Value> recv, int argc, |
4295 Handle<Value> argv[]) { | 4272 Local<Value> argv[]) { |
4296 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", | 4273 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Object::CallAsFunction()", |
4297 Value); | 4274 Value); |
4298 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4275 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4299 auto self = Utils::OpenHandle(this); | 4276 auto self = Utils::OpenHandle(this); |
4300 auto recv_obj = Utils::OpenHandle(*recv); | 4277 auto recv_obj = Utils::OpenHandle(*recv); |
4301 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4278 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4302 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4279 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4303 i::Handle<i::JSFunction> fun; | 4280 i::Handle<i::JSFunction> fun; |
4304 if (self->IsJSFunction()) { | 4281 if (self->IsJSFunction()) { |
4305 fun = i::Handle<i::JSFunction>::cast(self); | 4282 fun = i::Handle<i::JSFunction>::cast(self); |
4306 } else { | 4283 } else { |
4307 i::Handle<i::Object> delegate; | 4284 i::Handle<i::Object> delegate; |
4308 has_pending_exception = !i::Execution::TryGetFunctionDelegate(isolate, self) | 4285 has_pending_exception = !i::Execution::TryGetFunctionDelegate(isolate, self) |
4309 .ToHandle(&delegate); | 4286 .ToHandle(&delegate); |
4310 RETURN_ON_FAILED_EXECUTION(Value); | 4287 RETURN_ON_FAILED_EXECUTION(Value); |
4311 fun = i::Handle<i::JSFunction>::cast(delegate); | 4288 fun = i::Handle<i::JSFunction>::cast(delegate); |
4312 recv_obj = self; | 4289 recv_obj = self; |
4313 } | 4290 } |
4314 Local<Value> result; | 4291 Local<Value> result; |
4315 has_pending_exception = | 4292 has_pending_exception = |
4316 !ToLocal<Value>( | 4293 !ToLocal<Value>( |
4317 i::Execution::Call(isolate, fun, recv_obj, argc, args, true), | 4294 i::Execution::Call(isolate, fun, recv_obj, argc, args, true), |
4318 &result); | 4295 &result); |
4319 RETURN_ON_FAILED_EXECUTION(Value); | 4296 RETURN_ON_FAILED_EXECUTION(Value); |
4320 RETURN_ESCAPED(result); | 4297 RETURN_ESCAPED(result); |
4321 } | 4298 } |
4322 | 4299 |
4323 | 4300 |
4324 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv, int argc, | 4301 Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc, |
4325 v8::Handle<v8::Value> argv[]) { | 4302 v8::Local<v8::Value> argv[]) { |
4326 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4303 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4327 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4304 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
4328 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), | 4305 RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast), |
4329 Value); | 4306 Value); |
4330 } | 4307 } |
4331 | 4308 |
4332 | 4309 |
4333 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, | 4310 MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc, |
4334 Local<Value> argv[]) { | 4311 Local<Value> argv[]) { |
4335 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, | 4312 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, |
4336 "v8::Object::CallAsConstructor()", Value); | 4313 "v8::Object::CallAsConstructor()", Value); |
4337 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4314 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4338 auto self = Utils::OpenHandle(this); | 4315 auto self = Utils::OpenHandle(this); |
4339 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4316 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4340 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4317 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4341 if (self->IsJSFunction()) { | 4318 if (self->IsJSFunction()) { |
4342 auto fun = i::Handle<i::JSFunction>::cast(self); | 4319 auto fun = i::Handle<i::JSFunction>::cast(self); |
4343 Local<Value> result; | 4320 Local<Value> result; |
4344 has_pending_exception = | 4321 has_pending_exception = |
4345 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); | 4322 !ToLocal<Value>(i::Execution::New(fun, argc, args), &result); |
4346 RETURN_ON_FAILED_EXECUTION(Value); | 4323 RETURN_ON_FAILED_EXECUTION(Value); |
4347 RETURN_ESCAPED(result); | 4324 RETURN_ESCAPED(result); |
4348 } | 4325 } |
4349 i::Handle<i::Object> delegate; | 4326 i::Handle<i::Object> delegate; |
4350 has_pending_exception = !i::Execution::TryGetConstructorDelegate( | 4327 has_pending_exception = !i::Execution::TryGetConstructorDelegate( |
4351 isolate, self).ToHandle(&delegate); | 4328 isolate, self).ToHandle(&delegate); |
4352 RETURN_ON_FAILED_EXECUTION(Value); | 4329 RETURN_ON_FAILED_EXECUTION(Value); |
4353 if (!delegate->IsUndefined()) { | 4330 if (!delegate->IsUndefined()) { |
4354 auto fun = i::Handle<i::JSFunction>::cast(delegate); | 4331 auto fun = i::Handle<i::JSFunction>::cast(delegate); |
4355 Local<Value> result; | 4332 Local<Value> result; |
4356 has_pending_exception = | 4333 has_pending_exception = |
4357 !ToLocal<Value>(i::Execution::Call(isolate, fun, self, argc, args), | 4334 !ToLocal<Value>(i::Execution::Call(isolate, fun, self, argc, args), |
4358 &result); | 4335 &result); |
4359 RETURN_ON_FAILED_EXECUTION(Value); | 4336 RETURN_ON_FAILED_EXECUTION(Value); |
4360 DCHECK(!delegate->IsUndefined()); | 4337 DCHECK(!delegate->IsUndefined()); |
4361 RETURN_ESCAPED(result); | 4338 RETURN_ESCAPED(result); |
4362 } | 4339 } |
4363 return MaybeLocal<Value>(); | 4340 return MaybeLocal<Value>(); |
4364 } | 4341 } |
4365 | 4342 |
4366 | 4343 |
4367 Local<v8::Value> Object::CallAsConstructor(int argc, | 4344 Local<v8::Value> Object::CallAsConstructor(int argc, |
4368 v8::Handle<v8::Value> argv[]) { | 4345 v8::Local<v8::Value> argv[]) { |
4369 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4346 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4370 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); | 4347 Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv); |
4371 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); | 4348 RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value); |
4372 } | 4349 } |
4373 | 4350 |
4374 | 4351 |
4375 MaybeLocal<Function> Function::New(Local<Context> context, | 4352 MaybeLocal<Function> Function::New(Local<Context> context, |
4376 FunctionCallback callback, Local<Value> data, | 4353 FunctionCallback callback, Local<Value> data, |
4377 int length) { | 4354 int length) { |
4378 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); | 4355 i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); |
(...skipping 11 matching lines...) Expand all Loading... |
4390 } | 4367 } |
4391 | 4368 |
4392 | 4369 |
4393 Local<v8::Object> Function::NewInstance() const { | 4370 Local<v8::Object> Function::NewInstance() const { |
4394 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) | 4371 return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, NULL) |
4395 .FromMaybe(Local<Object>()); | 4372 .FromMaybe(Local<Object>()); |
4396 } | 4373 } |
4397 | 4374 |
4398 | 4375 |
4399 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, | 4376 MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc, |
4400 v8::Handle<v8::Value> argv[]) const { | 4377 v8::Local<v8::Value> argv[]) const { |
4401 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", | 4378 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::NewInstance()", |
4402 Object); | 4379 Object); |
4403 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4380 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4404 auto self = Utils::OpenHandle(this); | 4381 auto self = Utils::OpenHandle(this); |
4405 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4382 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4406 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4383 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4407 Local<Object> result; | 4384 Local<Object> result; |
4408 has_pending_exception = | 4385 has_pending_exception = |
4409 !ToLocal<Object>(i::Execution::New(self, argc, args), &result); | 4386 !ToLocal<Object>(i::Execution::New(self, argc, args), &result); |
4410 RETURN_ON_FAILED_EXECUTION(Object); | 4387 RETURN_ON_FAILED_EXECUTION(Object); |
4411 RETURN_ESCAPED(result); | 4388 RETURN_ESCAPED(result); |
4412 } | 4389 } |
4413 | 4390 |
4414 | 4391 |
4415 Local<v8::Object> Function::NewInstance(int argc, | 4392 Local<v8::Object> Function::NewInstance(int argc, |
4416 v8::Handle<v8::Value> argv[]) const { | 4393 v8::Local<v8::Value> argv[]) const { |
4417 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4394 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4418 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); | 4395 RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object); |
4419 } | 4396 } |
4420 | 4397 |
4421 | 4398 |
4422 MaybeLocal<v8::Value> Function::Call(Local<Context> context, | 4399 MaybeLocal<v8::Value> Function::Call(Local<Context> context, |
4423 v8::Handle<v8::Value> recv, int argc, | 4400 v8::Local<v8::Value> recv, int argc, |
4424 v8::Handle<v8::Value> argv[]) { | 4401 v8::Local<v8::Value> argv[]) { |
4425 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); | 4402 PREPARE_FOR_EXECUTION_WITH_CALLBACK(context, "v8::Function::Call()", Value); |
4426 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 4403 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
4427 auto self = Utils::OpenHandle(this); | 4404 auto self = Utils::OpenHandle(this); |
4428 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4405 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
4429 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4406 STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**)); |
4430 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4407 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4431 Local<Value> result; | 4408 Local<Value> result; |
4432 has_pending_exception = | 4409 has_pending_exception = |
4433 !ToLocal<Value>( | 4410 !ToLocal<Value>( |
4434 i::Execution::Call(isolate, self, recv_obj, argc, args, true), | 4411 i::Execution::Call(isolate, self, recv_obj, argc, args, true), |
4435 &result); | 4412 &result); |
4436 RETURN_ON_FAILED_EXECUTION(Value); | 4413 RETURN_ON_FAILED_EXECUTION(Value); |
4437 RETURN_ESCAPED(result); | 4414 RETURN_ESCAPED(result); |
4438 } | 4415 } |
4439 | 4416 |
4440 | 4417 |
4441 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc, | 4418 Local<v8::Value> Function::Call(v8::Local<v8::Value> recv, int argc, |
4442 v8::Handle<v8::Value> argv[]) { | 4419 v8::Local<v8::Value> argv[]) { |
4443 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 4420 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
4444 RETURN_TO_LOCAL_UNCHECKED(Call(context, recv, argc, argv), Value); | 4421 RETURN_TO_LOCAL_UNCHECKED(Call(context, recv, argc, argv), Value); |
4445 } | 4422 } |
4446 | 4423 |
4447 | 4424 |
4448 void Function::SetName(v8::Handle<v8::String> name) { | 4425 void Function::SetName(v8::Local<v8::String> name) { |
4449 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4426 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4450 func->shared()->set_name(*Utils::OpenHandle(*name)); | 4427 func->shared()->set_name(*Utils::OpenHandle(*name)); |
4451 } | 4428 } |
4452 | 4429 |
4453 | 4430 |
4454 Handle<Value> Function::GetName() const { | 4431 Local<Value> Function::GetName() const { |
4455 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4432 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4456 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name(), | 4433 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name(), |
4457 func->GetIsolate())); | 4434 func->GetIsolate())); |
4458 } | 4435 } |
4459 | 4436 |
4460 | 4437 |
4461 Handle<Value> Function::GetInferredName() const { | 4438 Local<Value> Function::GetInferredName() const { |
4462 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4439 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4463 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), | 4440 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->inferred_name(), |
4464 func->GetIsolate())); | 4441 func->GetIsolate())); |
4465 } | 4442 } |
4466 | 4443 |
4467 | 4444 |
4468 Handle<Value> Function::GetDisplayName() const { | 4445 Local<Value> Function::GetDisplayName() const { |
4469 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4446 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4470 ENTER_V8(isolate); | 4447 ENTER_V8(isolate); |
4471 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4448 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4472 i::Handle<i::String> property_name = | 4449 i::Handle<i::String> property_name = |
4473 isolate->factory()->NewStringFromStaticChars("displayName"); | 4450 isolate->factory()->NewStringFromStaticChars("displayName"); |
4474 i::Handle<i::Object> value = | 4451 i::Handle<i::Object> value = |
4475 i::JSReceiver::GetDataProperty(func, property_name); | 4452 i::JSReceiver::GetDataProperty(func, property_name); |
4476 if (value->IsString()) { | 4453 if (value->IsString()) { |
4477 i::Handle<i::String> name = i::Handle<i::String>::cast(value); | 4454 i::Handle<i::String> name = i::Handle<i::String>::cast(value); |
4478 if (name->length() > 0) return Utils::ToLocal(name); | 4455 if (name->length() > 0) return Utils::ToLocal(name); |
4479 } | 4456 } |
4480 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); | 4457 return ToApiHandle<Primitive>(isolate->factory()->undefined_value()); |
4481 } | 4458 } |
4482 | 4459 |
4483 | 4460 |
4484 ScriptOrigin Function::GetScriptOrigin() const { | 4461 ScriptOrigin Function::GetScriptOrigin() const { |
4485 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4462 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4486 if (func->shared()->script()->IsScript()) { | 4463 if (func->shared()->script()->IsScript()) { |
4487 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4464 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4488 return GetScriptOriginForScript(func->GetIsolate(), script); | 4465 return GetScriptOriginForScript(func->GetIsolate(), script); |
4489 } | 4466 } |
4490 return v8::ScriptOrigin(Handle<Value>()); | 4467 return v8::ScriptOrigin(Local<Value>()); |
4491 } | 4468 } |
4492 | 4469 |
4493 | 4470 |
4494 const int Function::kLineOffsetNotFound = -1; | 4471 const int Function::kLineOffsetNotFound = -1; |
4495 | 4472 |
4496 | 4473 |
4497 int Function::GetScriptLineNumber() const { | 4474 int Function::GetScriptLineNumber() const { |
4498 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 4475 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
4499 if (func->shared()->script()->IsScript()) { | 4476 if (func->shared()->script()->IsScript()) { |
4500 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4477 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5309 | 5286 |
5310 Local<Value> v8::Object::SlowGetInternalField(int index) { | 5287 Local<Value> v8::Object::SlowGetInternalField(int index) { |
5311 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5288 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
5312 const char* location = "v8::Object::GetInternalField()"; | 5289 const char* location = "v8::Object::GetInternalField()"; |
5313 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); | 5290 if (!InternalFieldOK(obj, index, location)) return Local<Value>(); |
5314 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); | 5291 i::Handle<i::Object> value(obj->GetInternalField(index), obj->GetIsolate()); |
5315 return Utils::ToLocal(value); | 5292 return Utils::ToLocal(value); |
5316 } | 5293 } |
5317 | 5294 |
5318 | 5295 |
5319 void v8::Object::SetInternalField(int index, v8::Handle<Value> value) { | 5296 void v8::Object::SetInternalField(int index, v8::Local<Value> value) { |
5320 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5297 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
5321 const char* location = "v8::Object::SetInternalField()"; | 5298 const char* location = "v8::Object::SetInternalField()"; |
5322 if (!InternalFieldOK(obj, index, location)) return; | 5299 if (!InternalFieldOK(obj, index, location)) return; |
5323 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 5300 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
5324 obj->SetInternalField(index, *val); | 5301 obj->SetInternalField(index, *val); |
5325 } | 5302 } |
5326 | 5303 |
5327 | 5304 |
5328 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { | 5305 void* v8::Object::SlowGetAlignedPointerFromInternalField(int index) { |
5329 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 5306 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5425 return i::InitializeICU(icu_data_file); | 5402 return i::InitializeICU(icu_data_file); |
5426 } | 5403 } |
5427 | 5404 |
5428 | 5405 |
5429 const char* v8::V8::GetVersion() { | 5406 const char* v8::V8::GetVersion() { |
5430 return i::Version::GetVersion(); | 5407 return i::Version::GetVersion(); |
5431 } | 5408 } |
5432 | 5409 |
5433 | 5410 |
5434 static i::Handle<i::Context> CreateEnvironment( | 5411 static i::Handle<i::Context> CreateEnvironment( |
5435 i::Isolate* isolate, | 5412 i::Isolate* isolate, v8::ExtensionConfiguration* extensions, |
5436 v8::ExtensionConfiguration* extensions, | 5413 v8::Local<ObjectTemplate> global_template, |
5437 v8::Handle<ObjectTemplate> global_template, | 5414 v8::Local<Value> maybe_global_proxy) { |
5438 v8::Handle<Value> maybe_global_proxy) { | |
5439 i::Handle<i::Context> env; | 5415 i::Handle<i::Context> env; |
5440 | 5416 |
5441 // Enter V8 via an ENTER_V8 scope. | 5417 // Enter V8 via an ENTER_V8 scope. |
5442 { | 5418 { |
5443 ENTER_V8(isolate); | 5419 ENTER_V8(isolate); |
5444 v8::Handle<ObjectTemplate> proxy_template = global_template; | 5420 v8::Local<ObjectTemplate> proxy_template = global_template; |
5445 i::Handle<i::FunctionTemplateInfo> proxy_constructor; | 5421 i::Handle<i::FunctionTemplateInfo> proxy_constructor; |
5446 i::Handle<i::FunctionTemplateInfo> global_constructor; | 5422 i::Handle<i::FunctionTemplateInfo> global_constructor; |
5447 | 5423 |
5448 if (!global_template.IsEmpty()) { | 5424 if (!global_template.IsEmpty()) { |
5449 // Make sure that the global_template has a constructor. | 5425 // Make sure that the global_template has a constructor. |
5450 global_constructor = EnsureConstructor(isolate, *global_template); | 5426 global_constructor = EnsureConstructor(isolate, *global_template); |
5451 | 5427 |
5452 // Create a fresh template for the global proxy object. | 5428 // Create a fresh template for the global proxy object. |
5453 proxy_template = ObjectTemplate::New( | 5429 proxy_template = ObjectTemplate::New( |
5454 reinterpret_cast<v8::Isolate*>(isolate)); | 5430 reinterpret_cast<v8::Isolate*>(isolate)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5490 proxy_constructor->access_check_info()); | 5466 proxy_constructor->access_check_info()); |
5491 global_constructor->set_needs_access_check( | 5467 global_constructor->set_needs_access_check( |
5492 proxy_constructor->needs_access_check()); | 5468 proxy_constructor->needs_access_check()); |
5493 } | 5469 } |
5494 } | 5470 } |
5495 // Leave V8. | 5471 // Leave V8. |
5496 | 5472 |
5497 return env; | 5473 return env; |
5498 } | 5474 } |
5499 | 5475 |
5500 Local<Context> v8::Context::New( | 5476 Local<Context> v8::Context::New(v8::Isolate* external_isolate, |
5501 v8::Isolate* external_isolate, | 5477 v8::ExtensionConfiguration* extensions, |
5502 v8::ExtensionConfiguration* extensions, | 5478 v8::Local<ObjectTemplate> global_template, |
5503 v8::Handle<ObjectTemplate> global_template, | 5479 v8::Local<Value> global_object) { |
5504 v8::Handle<Value> global_object) { | |
5505 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); | 5480 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); |
5506 LOG_API(isolate, "Context::New"); | 5481 LOG_API(isolate, "Context::New"); |
5507 i::HandleScope scope(isolate); | 5482 i::HandleScope scope(isolate); |
5508 ExtensionConfiguration no_extensions; | 5483 ExtensionConfiguration no_extensions; |
5509 if (extensions == NULL) extensions = &no_extensions; | 5484 if (extensions == NULL) extensions = &no_extensions; |
5510 i::Handle<i::Context> env = | 5485 i::Handle<i::Context> env = |
5511 CreateEnvironment(isolate, extensions, global_template, global_object); | 5486 CreateEnvironment(isolate, extensions, global_template, global_object); |
5512 if (env.is_null()) { | 5487 if (env.is_null()) { |
5513 if (isolate->has_pending_exception()) { | 5488 if (isolate->has_pending_exception()) { |
5514 isolate->OptionalRescheduleException(true); | 5489 isolate->OptionalRescheduleException(true); |
5515 } | 5490 } |
5516 return Local<Context>(); | 5491 return Local<Context>(); |
5517 } | 5492 } |
5518 return Utils::ToLocal(scope.CloseAndEscape(env)); | 5493 return Utils::ToLocal(scope.CloseAndEscape(env)); |
5519 } | 5494 } |
5520 | 5495 |
5521 | 5496 |
5522 void v8::Context::SetSecurityToken(Handle<Value> token) { | 5497 void v8::Context::SetSecurityToken(Local<Value> token) { |
5523 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5498 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5524 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); | 5499 i::Handle<i::Object> token_handle = Utils::OpenHandle(*token); |
5525 env->set_security_token(*token_handle); | 5500 env->set_security_token(*token_handle); |
5526 } | 5501 } |
5527 | 5502 |
5528 | 5503 |
5529 void v8::Context::UseDefaultSecurityToken() { | 5504 void v8::Context::UseDefaultSecurityToken() { |
5530 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5505 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5531 env->set_security_token(env->global_object()); | 5506 env->set_security_token(env->global_object()); |
5532 } | 5507 } |
5533 | 5508 |
5534 | 5509 |
5535 Handle<Value> v8::Context::GetSecurityToken() { | 5510 Local<Value> v8::Context::GetSecurityToken() { |
5536 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5511 i::Handle<i::Context> env = Utils::OpenHandle(this); |
5537 i::Isolate* isolate = env->GetIsolate(); | 5512 i::Isolate* isolate = env->GetIsolate(); |
5538 i::Object* security_token = env->security_token(); | 5513 i::Object* security_token = env->security_token(); |
5539 i::Handle<i::Object> token_handle(security_token, isolate); | 5514 i::Handle<i::Object> token_handle(security_token, isolate); |
5540 return Utils::ToLocal(token_handle); | 5515 return Utils::ToLocal(token_handle); |
5541 } | 5516 } |
5542 | 5517 |
5543 | 5518 |
5544 v8::Isolate* Context::GetIsolate() { | 5519 v8::Isolate* Context::GetIsolate() { |
5545 i::Handle<i::Context> env = Utils::OpenHandle(this); | 5520 i::Handle<i::Context> env = Utils::OpenHandle(this); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5585 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); | 5560 allow ? isolate->heap()->true_value() : isolate->heap()->false_value()); |
5586 } | 5561 } |
5587 | 5562 |
5588 | 5563 |
5589 bool Context::IsCodeGenerationFromStringsAllowed() { | 5564 bool Context::IsCodeGenerationFromStringsAllowed() { |
5590 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5565 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5591 return !context->allow_code_gen_from_strings()->IsFalse(); | 5566 return !context->allow_code_gen_from_strings()->IsFalse(); |
5592 } | 5567 } |
5593 | 5568 |
5594 | 5569 |
5595 void Context::SetErrorMessageForCodeGenerationFromStrings( | 5570 void Context::SetErrorMessageForCodeGenerationFromStrings(Local<String> error) { |
5596 Handle<String> error) { | |
5597 i::Handle<i::Context> context = Utils::OpenHandle(this); | 5571 i::Handle<i::Context> context = Utils::OpenHandle(this); |
5598 i::Handle<i::String> error_handle = Utils::OpenHandle(*error); | 5572 i::Handle<i::String> error_handle = Utils::OpenHandle(*error); |
5599 context->set_error_message_for_code_gen_from_strings(*error_handle); | 5573 context->set_error_message_for_code_gen_from_strings(*error_handle); |
5600 } | 5574 } |
5601 | 5575 |
5602 | 5576 |
5603 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { | 5577 MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) { |
5604 PREPARE_FOR_EXECUTION(context, "v8::ObjectTemplate::NewInstance()", Object); | 5578 PREPARE_FOR_EXECUTION(context, "v8::ObjectTemplate::NewInstance()", Object); |
5605 auto self = Utils::OpenHandle(this); | 5579 auto self = Utils::OpenHandle(this); |
5606 Local<Object> result; | 5580 Local<Object> result; |
(...skipping 21 matching lines...) Expand all Loading... |
5628 RETURN_ESCAPED(result); | 5602 RETURN_ESCAPED(result); |
5629 } | 5603 } |
5630 | 5604 |
5631 | 5605 |
5632 Local<v8::Function> FunctionTemplate::GetFunction() { | 5606 Local<v8::Function> FunctionTemplate::GetFunction() { |
5633 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 5607 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
5634 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); | 5608 RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function); |
5635 } | 5609 } |
5636 | 5610 |
5637 | 5611 |
5638 bool FunctionTemplate::HasInstance(v8::Handle<v8::Value> value) { | 5612 bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) { |
5639 auto self = Utils::OpenHandle(this); | 5613 auto self = Utils::OpenHandle(this); |
5640 auto obj = Utils::OpenHandle(*value); | 5614 auto obj = Utils::OpenHandle(*value); |
5641 return self->IsTemplateFor(*obj); | 5615 return self->IsTemplateFor(*obj); |
5642 } | 5616 } |
5643 | 5617 |
5644 | 5618 |
5645 Local<External> v8::External::New(Isolate* isolate, void* value) { | 5619 Local<External> v8::External::New(Isolate* isolate, void* value) { |
5646 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); | 5620 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); |
5647 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5621 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5648 LOG_API(i_isolate, "External::New"); | 5622 LOG_API(i_isolate, "External::New"); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5784 | 5758 |
5785 | 5759 |
5786 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, | 5760 MaybeLocal<String> String::NewFromTwoByte(Isolate* isolate, |
5787 const uint16_t* data, | 5761 const uint16_t* data, |
5788 v8::NewStringType type, int length) { | 5762 v8::NewStringType type, int length) { |
5789 return NewString(isolate, "v8::String::NewFromTwoByte()", | 5763 return NewString(isolate, "v8::String::NewFromTwoByte()", |
5790 "String::NewFromTwoByte", data, type, length); | 5764 "String::NewFromTwoByte", data, type, length); |
5791 } | 5765 } |
5792 | 5766 |
5793 | 5767 |
5794 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { | 5768 Local<String> v8::String::Concat(Local<String> left, Local<String> right) { |
5795 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5769 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
5796 i::Isolate* isolate = left_string->GetIsolate(); | 5770 i::Isolate* isolate = left_string->GetIsolate(); |
5797 ENTER_V8(isolate); | 5771 ENTER_V8(isolate); |
5798 LOG_API(isolate, "v8::String::Concat"); | 5772 LOG_API(isolate, "v8::String::Concat"); |
5799 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5773 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5800 // If we are steering towards a range error, do not wait for the error to be | 5774 // If we are steering towards a range error, do not wait for the error to be |
5801 // thrown, and return the null handle instead. | 5775 // thrown, and return the null handle instead. |
5802 if (left_string->length() + right_string->length() > i::String::kMaxLength) { | 5776 if (left_string->length() + right_string->length() > i::String::kMaxLength) { |
5803 return Local<String>(); | 5777 return Local<String>(); |
5804 } | 5778 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5973 | 5947 |
5974 bool v8::BooleanObject::ValueOf() const { | 5948 bool v8::BooleanObject::ValueOf() const { |
5975 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5949 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5976 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5950 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5977 i::Isolate* isolate = jsvalue->GetIsolate(); | 5951 i::Isolate* isolate = jsvalue->GetIsolate(); |
5978 LOG_API(isolate, "BooleanObject::BooleanValue"); | 5952 LOG_API(isolate, "BooleanObject::BooleanValue"); |
5979 return jsvalue->value()->IsTrue(); | 5953 return jsvalue->value()->IsTrue(); |
5980 } | 5954 } |
5981 | 5955 |
5982 | 5956 |
5983 Local<v8::Value> v8::StringObject::New(Handle<String> value) { | 5957 Local<v8::Value> v8::StringObject::New(Local<String> value) { |
5984 i::Handle<i::String> string = Utils::OpenHandle(*value); | 5958 i::Handle<i::String> string = Utils::OpenHandle(*value); |
5985 i::Isolate* isolate = string->GetIsolate(); | 5959 i::Isolate* isolate = string->GetIsolate(); |
5986 LOG_API(isolate, "StringObject::New"); | 5960 LOG_API(isolate, "StringObject::New"); |
5987 ENTER_V8(isolate); | 5961 ENTER_V8(isolate); |
5988 i::Handle<i::Object> obj = | 5962 i::Handle<i::Object> obj = |
5989 i::Object::ToObject(isolate, string).ToHandleChecked(); | 5963 i::Object::ToObject(isolate, string).ToHandleChecked(); |
5990 return Utils::ToLocal(obj); | 5964 return Utils::ToLocal(obj); |
5991 } | 5965 } |
5992 | 5966 |
5993 | 5967 |
5994 Local<v8::String> v8::StringObject::ValueOf() const { | 5968 Local<v8::String> v8::StringObject::ValueOf() const { |
5995 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5969 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5996 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5970 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5997 i::Isolate* isolate = jsvalue->GetIsolate(); | 5971 i::Isolate* isolate = jsvalue->GetIsolate(); |
5998 LOG_API(isolate, "StringObject::StringValue"); | 5972 LOG_API(isolate, "StringObject::StringValue"); |
5999 return Utils::ToLocal( | 5973 return Utils::ToLocal( |
6000 i::Handle<i::String>(i::String::cast(jsvalue->value()))); | 5974 i::Handle<i::String>(i::String::cast(jsvalue->value()))); |
6001 } | 5975 } |
6002 | 5976 |
6003 | 5977 |
6004 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { | 5978 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Local<Symbol> value) { |
6005 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5979 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6006 LOG_API(i_isolate, "SymbolObject::New"); | 5980 LOG_API(i_isolate, "SymbolObject::New"); |
6007 ENTER_V8(i_isolate); | 5981 ENTER_V8(i_isolate); |
6008 i::Handle<i::Object> obj = i::Object::ToObject( | 5982 i::Handle<i::Object> obj = i::Object::ToObject( |
6009 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); | 5983 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); |
6010 return Utils::ToLocal(obj); | 5984 return Utils::ToLocal(obj); |
6011 } | 5985 } |
6012 | 5986 |
6013 | 5987 |
6014 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 5988 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6077 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 6051 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
6078 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 6052 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
6079 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 6053 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
6080 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf))); | 6054 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf))); |
6081 return isolate->factory()->InternalizeOneByteString( | 6055 return isolate->factory()->InternalizeOneByteString( |
6082 i::Vector<const uint8_t>(flags_buf, num_flags)); | 6056 i::Vector<const uint8_t>(flags_buf, num_flags)); |
6083 } | 6057 } |
6084 | 6058 |
6085 | 6059 |
6086 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, | 6060 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, |
6087 Handle<String> pattern, Flags flags) { | 6061 Local<String> pattern, Flags flags) { |
6088 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); | 6062 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); |
6089 Local<v8::RegExp> result; | 6063 Local<v8::RegExp> result; |
6090 has_pending_exception = | 6064 has_pending_exception = |
6091 !ToLocal<RegExp>(i::Execution::NewJSRegExp(Utils::OpenHandle(*pattern), | 6065 !ToLocal<RegExp>(i::Execution::NewJSRegExp(Utils::OpenHandle(*pattern), |
6092 RegExpFlagsToString(flags)), | 6066 RegExpFlagsToString(flags)), |
6093 &result); | 6067 &result); |
6094 RETURN_ON_FAILED_EXECUTION(RegExp); | 6068 RETURN_ON_FAILED_EXECUTION(RegExp); |
6095 RETURN_ESCAPED(result); | 6069 RETURN_ESCAPED(result); |
6096 } | 6070 } |
6097 | 6071 |
6098 | 6072 |
6099 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, Flags flags) { | 6073 Local<v8::RegExp> v8::RegExp::New(Local<String> pattern, Flags flags) { |
6100 auto isolate = | 6074 auto isolate = |
6101 reinterpret_cast<Isolate*>(Utils::OpenHandle(*pattern)->GetIsolate()); | 6075 reinterpret_cast<Isolate*>(Utils::OpenHandle(*pattern)->GetIsolate()); |
6102 auto context = isolate->GetCurrentContext(); | 6076 auto context = isolate->GetCurrentContext(); |
6103 RETURN_TO_LOCAL_UNCHECKED(New(context, pattern, flags), RegExp); | 6077 RETURN_TO_LOCAL_UNCHECKED(New(context, pattern, flags), RegExp); |
6104 } | 6078 } |
6105 | 6079 |
6106 | 6080 |
6107 Local<v8::String> v8::RegExp::GetSource() const { | 6081 Local<v8::String> v8::RegExp::GetSource() const { |
6108 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6082 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
6109 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); | 6083 return Utils::ToLocal(i::Handle<i::String>(obj->Pattern())); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6413 } | 6387 } |
6414 | 6388 |
6415 | 6389 |
6416 Local<Promise> Promise::Resolver::GetPromise() { | 6390 Local<Promise> Promise::Resolver::GetPromise() { |
6417 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); | 6391 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
6418 return Local<Promise>::Cast(Utils::ToLocal(promise)); | 6392 return Local<Promise>::Cast(Utils::ToLocal(promise)); |
6419 } | 6393 } |
6420 | 6394 |
6421 | 6395 |
6422 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, | 6396 Maybe<bool> Promise::Resolver::Resolve(Local<Context> context, |
6423 Handle<Value> value) { | 6397 Local<Value> value) { |
6424 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6398 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); |
6425 auto self = Utils::OpenHandle(this); | 6399 auto self = Utils::OpenHandle(this); |
6426 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6400 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
6427 has_pending_exception = i::Execution::Call( | 6401 has_pending_exception = i::Execution::Call( |
6428 isolate, | 6402 isolate, |
6429 isolate->promise_resolve(), | 6403 isolate->promise_resolve(), |
6430 isolate->factory()->undefined_value(), | 6404 isolate->factory()->undefined_value(), |
6431 arraysize(argv), argv, | 6405 arraysize(argv), argv, |
6432 false).is_null(); | 6406 false).is_null(); |
6433 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6407 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6434 return Just(true); | 6408 return Just(true); |
6435 } | 6409 } |
6436 | 6410 |
6437 | 6411 |
6438 void Promise::Resolver::Resolve(Handle<Value> value) { | 6412 void Promise::Resolver::Resolve(Local<Value> value) { |
6439 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6413 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6440 USE(Resolve(context, value)); | 6414 USE(Resolve(context, value)); |
6441 } | 6415 } |
6442 | 6416 |
6443 | 6417 |
6444 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, | 6418 Maybe<bool> Promise::Resolver::Reject(Local<Context> context, |
6445 Handle<Value> value) { | 6419 Local<Value> value) { |
6446 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); | 6420 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "Promise::Resolver::Resolve", bool); |
6447 auto self = Utils::OpenHandle(this); | 6421 auto self = Utils::OpenHandle(this); |
6448 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; | 6422 i::Handle<i::Object> argv[] = {self, Utils::OpenHandle(*value)}; |
6449 has_pending_exception = i::Execution::Call( | 6423 has_pending_exception = i::Execution::Call( |
6450 isolate, | 6424 isolate, |
6451 isolate->promise_reject(), | 6425 isolate->promise_reject(), |
6452 isolate->factory()->undefined_value(), | 6426 isolate->factory()->undefined_value(), |
6453 arraysize(argv), argv, | 6427 arraysize(argv), argv, |
6454 false).is_null(); | 6428 false).is_null(); |
6455 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 6429 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
6456 return Just(true); | 6430 return Just(true); |
6457 } | 6431 } |
6458 | 6432 |
6459 | 6433 |
6460 void Promise::Resolver::Reject(Handle<Value> value) { | 6434 void Promise::Resolver::Reject(Local<Value> value) { |
6461 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6435 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6462 USE(Reject(context, value)); | 6436 USE(Reject(context, value)); |
6463 } | 6437 } |
6464 | 6438 |
6465 | 6439 |
6466 MaybeLocal<Promise> Promise::Chain(Local<Context> context, | 6440 MaybeLocal<Promise> Promise::Chain(Local<Context> context, |
6467 Handle<Function> handler) { | 6441 Local<Function> handler) { |
6468 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); | 6442 PREPARE_FOR_EXECUTION(context, "Promise::Chain", Promise); |
6469 auto self = Utils::OpenHandle(this); | 6443 auto self = Utils::OpenHandle(this); |
6470 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; | 6444 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; |
6471 i::Handle<i::Object> result; | 6445 i::Handle<i::Object> result; |
6472 has_pending_exception = | 6446 has_pending_exception = |
6473 !i::Execution::Call(isolate, isolate->promise_chain(), self, | 6447 !i::Execution::Call(isolate, isolate->promise_chain(), self, |
6474 arraysize(argv), argv, false).ToHandle(&result); | 6448 arraysize(argv), argv, false).ToHandle(&result); |
6475 RETURN_ON_FAILED_EXECUTION(Promise); | 6449 RETURN_ON_FAILED_EXECUTION(Promise); |
6476 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6450 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6477 } | 6451 } |
6478 | 6452 |
6479 | 6453 |
6480 Local<Promise> Promise::Chain(Handle<Function> handler) { | 6454 Local<Promise> Promise::Chain(Local<Function> handler) { |
6481 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6455 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6482 RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise); | 6456 RETURN_TO_LOCAL_UNCHECKED(Chain(context, handler), Promise); |
6483 } | 6457 } |
6484 | 6458 |
6485 | 6459 |
6486 MaybeLocal<Promise> Promise::Catch(Local<Context> context, | 6460 MaybeLocal<Promise> Promise::Catch(Local<Context> context, |
6487 Handle<Function> handler) { | 6461 Local<Function> handler) { |
6488 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise); | 6462 PREPARE_FOR_EXECUTION(context, "Promise::Catch", Promise); |
6489 auto self = Utils::OpenHandle(this); | 6463 auto self = Utils::OpenHandle(this); |
6490 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6464 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
6491 i::Handle<i::Object> result; | 6465 i::Handle<i::Object> result; |
6492 has_pending_exception = | 6466 has_pending_exception = |
6493 !i::Execution::Call(isolate, isolate->promise_catch(), self, | 6467 !i::Execution::Call(isolate, isolate->promise_catch(), self, |
6494 arraysize(argv), argv, false).ToHandle(&result); | 6468 arraysize(argv), argv, false).ToHandle(&result); |
6495 RETURN_ON_FAILED_EXECUTION(Promise); | 6469 RETURN_ON_FAILED_EXECUTION(Promise); |
6496 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6470 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6497 } | 6471 } |
6498 | 6472 |
6499 | 6473 |
6500 Local<Promise> Promise::Catch(Handle<Function> handler) { | 6474 Local<Promise> Promise::Catch(Local<Function> handler) { |
6501 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6475 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6502 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); | 6476 RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise); |
6503 } | 6477 } |
6504 | 6478 |
6505 | 6479 |
6506 MaybeLocal<Promise> Promise::Then(Local<Context> context, | 6480 MaybeLocal<Promise> Promise::Then(Local<Context> context, |
6507 Handle<Function> handler) { | 6481 Local<Function> handler) { |
6508 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise); | 6482 PREPARE_FOR_EXECUTION(context, "Promise::Then", Promise); |
6509 auto self = Utils::OpenHandle(this); | 6483 auto self = Utils::OpenHandle(this); |
6510 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6484 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
6511 i::Handle<i::Object> result; | 6485 i::Handle<i::Object> result; |
6512 has_pending_exception = | 6486 has_pending_exception = |
6513 !i::Execution::Call(isolate, isolate->promise_then(), self, | 6487 !i::Execution::Call(isolate, isolate->promise_then(), self, |
6514 arraysize(argv), argv, false).ToHandle(&result); | 6488 arraysize(argv), argv, false).ToHandle(&result); |
6515 RETURN_ON_FAILED_EXECUTION(Promise); | 6489 RETURN_ON_FAILED_EXECUTION(Promise); |
6516 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | 6490 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); |
6517 } | 6491 } |
6518 | 6492 |
6519 | 6493 |
6520 Local<Promise> Promise::Then(Handle<Function> handler) { | 6494 Local<Promise> Promise::Then(Local<Function> handler) { |
6521 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6495 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6522 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); | 6496 RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise); |
6523 } | 6497 } |
6524 | 6498 |
6525 | 6499 |
6526 bool Promise::HasHandler() { | 6500 bool Promise::HasHandler() { |
6527 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); | 6501 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
6528 i::Isolate* isolate = promise->GetIsolate(); | 6502 i::Isolate* isolate = promise->GetIsolate(); |
6529 LOG_API(isolate, "Promise::HasRejectHandler"); | 6503 LOG_API(isolate, "Promise::HasRejectHandler"); |
6530 ENTER_V8(isolate); | 6504 ENTER_V8(isolate); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6668 return static_cast<size_t>(obj->byte_length()->Number()); | 6642 return static_cast<size_t>(obj->byte_length()->Number()); |
6669 } | 6643 } |
6670 | 6644 |
6671 | 6645 |
6672 size_t v8::TypedArray::Length() { | 6646 size_t v8::TypedArray::Length() { |
6673 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); | 6647 i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); |
6674 return static_cast<size_t>(obj->length_value()); | 6648 return static_cast<size_t>(obj->length_value()); |
6675 } | 6649 } |
6676 | 6650 |
6677 | 6651 |
6678 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ | 6652 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ |
6679 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \ | 6653 Local<Type##Array> Type##Array::New(Local<ArrayBuffer> array_buffer, \ |
6680 size_t byte_offset, size_t length) { \ | 6654 size_t byte_offset, size_t length) { \ |
6681 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ | 6655 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ |
6682 LOG_API(isolate, \ | 6656 LOG_API(isolate, \ |
6683 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ | 6657 "v8::" #Type "Array::New(Local<ArrayBuffer>, size_t, size_t)"); \ |
6684 ENTER_V8(isolate); \ | 6658 ENTER_V8(isolate); \ |
6685 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6659 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
6686 "v8::" #Type \ | 6660 "v8::" #Type \ |
6687 "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \ | 6661 "Array::New(Local<ArrayBuffer>, size_t, size_t)", \ |
6688 "length exceeds max allowed value")) { \ | 6662 "length exceeds max allowed value")) { \ |
6689 return Local<Type##Array>(); \ | 6663 return Local<Type##Array>(); \ |
6690 } \ | 6664 } \ |
6691 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ | 6665 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); \ |
6692 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | 6666 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
6693 i::kExternal##Type##Array, buffer, byte_offset, length); \ | 6667 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
6694 return Utils::ToLocal##Type##Array(obj); \ | 6668 return Utils::ToLocal##Type##Array(obj); \ |
6695 } \ | 6669 } \ |
6696 Local<Type##Array> Type##Array::New( \ | 6670 Local<Type##Array> Type##Array::New( \ |
6697 Handle<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ | 6671 Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, \ |
6698 size_t length) { \ | 6672 size_t length) { \ |
6699 CHECK(i::FLAG_harmony_sharedarraybuffer); \ | 6673 CHECK(i::FLAG_harmony_sharedarraybuffer); \ |
6700 i::Isolate* isolate = \ | 6674 i::Isolate* isolate = \ |
6701 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ | 6675 Utils::OpenHandle(*shared_array_buffer)->GetIsolate(); \ |
6702 LOG_API(isolate, "v8::" #Type \ | 6676 LOG_API(isolate, "v8::" #Type \ |
6703 "Array::New(Handle<SharedArrayBuffer>, size_t, size_t)"); \ | 6677 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)"); \ |
6704 ENTER_V8(isolate); \ | 6678 ENTER_V8(isolate); \ |
6705 if (!Utils::ApiCheck( \ | 6679 if (!Utils::ApiCheck( \ |
6706 length <= static_cast<size_t>(i::Smi::kMaxValue), \ | 6680 length <= static_cast<size_t>(i::Smi::kMaxValue), \ |
6707 "v8::" #Type \ | 6681 "v8::" #Type \ |
6708 "Array::New(Handle<SharedArrayBuffer>, size_t, size_t)", \ | 6682 "Array::New(Local<SharedArrayBuffer>, size_t, size_t)", \ |
6709 "length exceeds max allowed value")) { \ | 6683 "length exceeds max allowed value")) { \ |
6710 return Local<Type##Array>(); \ | 6684 return Local<Type##Array>(); \ |
6711 } \ | 6685 } \ |
6712 i::Handle<i::JSArrayBuffer> buffer = \ | 6686 i::Handle<i::JSArrayBuffer> buffer = \ |
6713 Utils::OpenHandle(*shared_array_buffer); \ | 6687 Utils::OpenHandle(*shared_array_buffer); \ |
6714 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ | 6688 i::Handle<i::JSTypedArray> obj = isolate->factory()->NewJSTypedArray( \ |
6715 i::kExternal##Type##Array, buffer, byte_offset, length); \ | 6689 i::kExternal##Type##Array, buffer, byte_offset, length); \ |
6716 return Utils::ToLocal##Type##Array(obj); \ | 6690 return Utils::ToLocal##Type##Array(obj); \ |
6717 } | 6691 } |
6718 | 6692 |
6719 | 6693 |
6720 TYPED_ARRAYS(TYPED_ARRAY_NEW) | 6694 TYPED_ARRAYS(TYPED_ARRAY_NEW) |
6721 #undef TYPED_ARRAY_NEW | 6695 #undef TYPED_ARRAY_NEW |
6722 | 6696 |
6723 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer, | 6697 Local<DataView> DataView::New(Local<ArrayBuffer> array_buffer, |
6724 size_t byte_offset, size_t byte_length) { | 6698 size_t byte_offset, size_t byte_length) { |
6725 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); | 6699 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); |
6726 i::Isolate* isolate = buffer->GetIsolate(); | 6700 i::Isolate* isolate = buffer->GetIsolate(); |
6727 LOG_API(isolate, "v8::DataView::New(Handle<ArrayBuffer>, size_t, size_t)"); | 6701 LOG_API(isolate, "v8::DataView::New(Local<ArrayBuffer>, size_t, size_t)"); |
6728 ENTER_V8(isolate); | 6702 ENTER_V8(isolate); |
6729 i::Handle<i::JSDataView> obj = | 6703 i::Handle<i::JSDataView> obj = |
6730 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6704 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
6731 return Utils::ToLocal(obj); | 6705 return Utils::ToLocal(obj); |
6732 } | 6706 } |
6733 | 6707 |
6734 | 6708 |
6735 Local<DataView> DataView::New(Handle<SharedArrayBuffer> shared_array_buffer, | 6709 Local<DataView> DataView::New(Local<SharedArrayBuffer> shared_array_buffer, |
6736 size_t byte_offset, size_t byte_length) { | 6710 size_t byte_offset, size_t byte_length) { |
6737 CHECK(i::FLAG_harmony_sharedarraybuffer); | 6711 CHECK(i::FLAG_harmony_sharedarraybuffer); |
6738 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); | 6712 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*shared_array_buffer); |
6739 i::Isolate* isolate = buffer->GetIsolate(); | 6713 i::Isolate* isolate = buffer->GetIsolate(); |
6740 LOG_API(isolate, | 6714 LOG_API(isolate, |
6741 "v8::DataView::New(Handle<SharedArrayBuffer>, size_t, size_t)"); | 6715 "v8::DataView::New(Local<SharedArrayBuffer>, size_t, size_t)"); |
6742 ENTER_V8(isolate); | 6716 ENTER_V8(isolate); |
6743 i::Handle<i::JSDataView> obj = | 6717 i::Handle<i::JSDataView> obj = |
6744 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); | 6718 isolate->factory()->NewJSDataView(buffer, byte_offset, byte_length); |
6745 return Utils::ToLocal(obj); | 6719 return Utils::ToLocal(obj); |
6746 } | 6720 } |
6747 | 6721 |
6748 | 6722 |
6749 bool v8::SharedArrayBuffer::IsExternal() const { | 6723 bool v8::SharedArrayBuffer::IsExternal() const { |
6750 return Utils::OpenHandle(this)->is_external(); | 6724 return Utils::OpenHandle(this)->is_external(); |
6751 } | 6725 } |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7345 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7319 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7346 isolate->SetPromiseRejectCallback(callback); | 7320 isolate->SetPromiseRejectCallback(callback); |
7347 } | 7321 } |
7348 | 7322 |
7349 | 7323 |
7350 void Isolate::RunMicrotasks() { | 7324 void Isolate::RunMicrotasks() { |
7351 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks(); | 7325 reinterpret_cast<i::Isolate*>(this)->RunMicrotasks(); |
7352 } | 7326 } |
7353 | 7327 |
7354 | 7328 |
7355 void Isolate::EnqueueMicrotask(Handle<Function> microtask) { | 7329 void Isolate::EnqueueMicrotask(Local<Function> microtask) { |
7356 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7330 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7357 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask)); | 7331 isolate->EnqueueMicrotask(Utils::OpenHandle(*microtask)); |
7358 } | 7332 } |
7359 | 7333 |
7360 | 7334 |
7361 void Isolate::EnqueueMicrotask(MicrotaskCallback microtask, void* data) { | 7335 void Isolate::EnqueueMicrotask(MicrotaskCallback microtask, void* data) { |
7362 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7336 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7363 i::HandleScope scope(isolate); | 7337 i::HandleScope scope(isolate); |
7364 i::Handle<i::CallHandlerInfo> callback_info = | 7338 i::Handle<i::CallHandlerInfo> callback_info = |
7365 i::Handle<i::CallHandlerInfo>::cast( | 7339 i::Handle<i::CallHandlerInfo>::cast( |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7483 isolate->set_allow_code_gen_callback(callback); | 7457 isolate->set_allow_code_gen_callback(callback); |
7484 } | 7458 } |
7485 | 7459 |
7486 | 7460 |
7487 bool Isolate::IsDead() { | 7461 bool Isolate::IsDead() { |
7488 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7462 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7489 return isolate->IsDead(); | 7463 return isolate->IsDead(); |
7490 } | 7464 } |
7491 | 7465 |
7492 | 7466 |
7493 bool Isolate::AddMessageListener(MessageCallback that, Handle<Value> data) { | 7467 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { |
7494 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7468 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7495 ENTER_V8(isolate); | 7469 ENTER_V8(isolate); |
7496 i::HandleScope scope(isolate); | 7470 i::HandleScope scope(isolate); |
7497 NeanderArray listeners(isolate->factory()->message_listeners()); | 7471 NeanderArray listeners(isolate->factory()->message_listeners()); |
7498 NeanderObject obj(isolate, 2); | 7472 NeanderObject obj(isolate, 2); |
7499 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); | 7473 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); |
7500 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() | 7474 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
7501 : *Utils::OpenHandle(*data)); | 7475 : *Utils::OpenHandle(*data)); |
7502 listeners.add(isolate, obj.value()); | 7476 listeners.add(isolate, obj.value()); |
7503 return true; | 7477 return true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7571 void Isolate::VisitHandlesForPartialDependence( | 7545 void Isolate::VisitHandlesForPartialDependence( |
7572 PersistentHandleVisitor* visitor) { | 7546 PersistentHandleVisitor* visitor) { |
7573 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 7547 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
7574 i::DisallowHeapAllocation no_allocation; | 7548 i::DisallowHeapAllocation no_allocation; |
7575 VisitorAdapter visitor_adapter(visitor); | 7549 VisitorAdapter visitor_adapter(visitor); |
7576 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( | 7550 isolate->global_handles()->IterateAllRootsInNewSpaceWithClassIds( |
7577 &visitor_adapter); | 7551 &visitor_adapter); |
7578 } | 7552 } |
7579 | 7553 |
7580 | 7554 |
7581 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 7555 String::Utf8Value::Utf8Value(v8::Local<v8::Value> obj) |
7582 : str_(NULL), length_(0) { | 7556 : str_(NULL), length_(0) { |
7583 if (obj.IsEmpty()) return; | 7557 if (obj.IsEmpty()) return; |
7584 i::Isolate* isolate = i::Isolate::Current(); | 7558 i::Isolate* isolate = i::Isolate::Current(); |
7585 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 7559 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
7586 ENTER_V8(isolate); | 7560 ENTER_V8(isolate); |
7587 i::HandleScope scope(isolate); | 7561 i::HandleScope scope(isolate); |
7588 Local<Context> context = v8_isolate->GetCurrentContext(); | 7562 Local<Context> context = v8_isolate->GetCurrentContext(); |
7589 TryCatch try_catch(v8_isolate); | 7563 TryCatch try_catch(v8_isolate); |
7590 Handle<String> str; | 7564 Local<String> str; |
7591 if (!obj->ToString(context).ToLocal(&str)) return; | 7565 if (!obj->ToString(context).ToLocal(&str)) return; |
7592 i::Handle<i::String> i_str = Utils::OpenHandle(*str); | 7566 i::Handle<i::String> i_str = Utils::OpenHandle(*str); |
7593 length_ = v8::Utf8Length(*i_str, isolate); | 7567 length_ = v8::Utf8Length(*i_str, isolate); |
7594 str_ = i::NewArray<char>(length_ + 1); | 7568 str_ = i::NewArray<char>(length_ + 1); |
7595 str->WriteUtf8(str_); | 7569 str->WriteUtf8(str_); |
7596 } | 7570 } |
7597 | 7571 |
7598 | 7572 |
7599 String::Utf8Value::~Utf8Value() { | 7573 String::Utf8Value::~Utf8Value() { |
7600 i::DeleteArray(str_); | 7574 i::DeleteArray(str_); |
7601 } | 7575 } |
7602 | 7576 |
7603 | 7577 |
7604 String::Value::Value(v8::Handle<v8::Value> obj) | 7578 String::Value::Value(v8::Local<v8::Value> obj) : str_(NULL), length_(0) { |
7605 : str_(NULL), length_(0) { | |
7606 if (obj.IsEmpty()) return; | 7579 if (obj.IsEmpty()) return; |
7607 i::Isolate* isolate = i::Isolate::Current(); | 7580 i::Isolate* isolate = i::Isolate::Current(); |
7608 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); | 7581 Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate); |
7609 ENTER_V8(isolate); | 7582 ENTER_V8(isolate); |
7610 i::HandleScope scope(isolate); | 7583 i::HandleScope scope(isolate); |
7611 Local<Context> context = v8_isolate->GetCurrentContext(); | 7584 Local<Context> context = v8_isolate->GetCurrentContext(); |
7612 TryCatch try_catch(v8_isolate); | 7585 TryCatch try_catch(v8_isolate); |
7613 Handle<String> str; | 7586 Local<String> str; |
7614 if (!obj->ToString(context).ToLocal(&str)) return; | 7587 if (!obj->ToString(context).ToLocal(&str)) return; |
7615 length_ = str->Length(); | 7588 length_ = str->Length(); |
7616 str_ = i::NewArray<uint16_t>(length_ + 1); | 7589 str_ = i::NewArray<uint16_t>(length_ + 1); |
7617 str->Write(str_); | 7590 str->Write(str_); |
7618 } | 7591 } |
7619 | 7592 |
7620 | 7593 |
7621 String::Value::~Value() { | 7594 String::Value::~Value() { |
7622 i::DeleteArray(str_); | 7595 i::DeleteArray(str_); |
7623 } | 7596 } |
7624 | 7597 |
7625 | 7598 |
7626 #define DEFINE_ERROR(NAME) \ | 7599 #define DEFINE_ERROR(NAME) \ |
7627 Local<Value> Exception::NAME(v8::Handle<v8::String> raw_message) { \ | 7600 Local<Value> Exception::NAME(v8::Local<v8::String> raw_message) { \ |
7628 i::Isolate* isolate = i::Isolate::Current(); \ | 7601 i::Isolate* isolate = i::Isolate::Current(); \ |
7629 LOG_API(isolate, #NAME); \ | 7602 LOG_API(isolate, #NAME); \ |
7630 ENTER_V8(isolate); \ | 7603 ENTER_V8(isolate); \ |
7631 i::Object* error; \ | 7604 i::Object* error; \ |
7632 { \ | 7605 { \ |
7633 i::HandleScope scope(isolate); \ | 7606 i::HandleScope scope(isolate); \ |
7634 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ | 7607 i::Handle<i::String> message = Utils::OpenHandle(*raw_message); \ |
7635 error = *isolate->factory()->NewError("$" #NAME, message); \ | 7608 error = *isolate->factory()->NewError("$" #NAME, message); \ |
7636 } \ | 7609 } \ |
7637 i::Handle<i::Object> result(error, isolate); \ | 7610 i::Handle<i::Object> result(error, isolate); \ |
7638 return Utils::ToLocal(result); \ | 7611 return Utils::ToLocal(result); \ |
7639 } | 7612 } |
7640 | 7613 |
7641 DEFINE_ERROR(RangeError) | 7614 DEFINE_ERROR(RangeError) |
7642 DEFINE_ERROR(ReferenceError) | 7615 DEFINE_ERROR(ReferenceError) |
7643 DEFINE_ERROR(SyntaxError) | 7616 DEFINE_ERROR(SyntaxError) |
7644 DEFINE_ERROR(TypeError) | 7617 DEFINE_ERROR(TypeError) |
7645 DEFINE_ERROR(Error) | 7618 DEFINE_ERROR(Error) |
7646 | 7619 |
7647 #undef DEFINE_ERROR | 7620 #undef DEFINE_ERROR |
7648 | 7621 |
7649 | 7622 |
7650 Local<Message> Exception::CreateMessage(Handle<Value> exception) { | 7623 Local<Message> Exception::CreateMessage(Local<Value> exception) { |
7651 i::Handle<i::Object> obj = Utils::OpenHandle(*exception); | 7624 i::Handle<i::Object> obj = Utils::OpenHandle(*exception); |
7652 if (!obj->IsHeapObject()) return Local<Message>(); | 7625 if (!obj->IsHeapObject()) return Local<Message>(); |
7653 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); | 7626 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate(); |
7654 ENTER_V8(isolate); | 7627 ENTER_V8(isolate); |
7655 i::HandleScope scope(isolate); | 7628 i::HandleScope scope(isolate); |
7656 return Utils::MessageToLocal( | 7629 return Utils::MessageToLocal( |
7657 scope.CloseAndEscape(isolate->CreateMessage(obj, NULL))); | 7630 scope.CloseAndEscape(isolate->CreateMessage(obj, NULL))); |
7658 } | 7631 } |
7659 | 7632 |
7660 | 7633 |
7661 Local<StackTrace> Exception::GetStackTrace(Handle<Value> exception) { | 7634 Local<StackTrace> Exception::GetStackTrace(Local<Value> exception) { |
7662 i::Handle<i::Object> obj = Utils::OpenHandle(*exception); | 7635 i::Handle<i::Object> obj = Utils::OpenHandle(*exception); |
7663 if (!obj->IsJSObject()) return Local<StackTrace>(); | 7636 if (!obj->IsJSObject()) return Local<StackTrace>(); |
7664 i::Handle<i::JSObject> js_obj = i::Handle<i::JSObject>::cast(obj); | 7637 i::Handle<i::JSObject> js_obj = i::Handle<i::JSObject>::cast(obj); |
7665 i::Isolate* isolate = js_obj->GetIsolate(); | 7638 i::Isolate* isolate = js_obj->GetIsolate(); |
7666 ENTER_V8(isolate); | 7639 ENTER_V8(isolate); |
7667 return Utils::StackTraceToLocal(isolate->GetDetailedStackTrace(js_obj)); | 7640 return Utils::StackTraceToLocal(isolate->GetDetailedStackTrace(js_obj)); |
7668 } | 7641 } |
7669 | 7642 |
7670 | 7643 |
7671 // --- D e b u g S u p p o r t --- | 7644 // --- D e b u g S u p p o r t --- |
7672 | 7645 |
7673 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { | 7646 bool Debug::SetDebugEventListener(EventCallback that, Local<Value> data) { |
7674 i::Isolate* isolate = i::Isolate::Current(); | 7647 i::Isolate* isolate = i::Isolate::Current(); |
7675 ENTER_V8(isolate); | 7648 ENTER_V8(isolate); |
7676 i::HandleScope scope(isolate); | 7649 i::HandleScope scope(isolate); |
7677 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); | 7650 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); |
7678 if (that != NULL) { | 7651 if (that != NULL) { |
7679 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); | 7652 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); |
7680 } | 7653 } |
7681 isolate->debug()->SetEventListener(foreign, | 7654 isolate->debug()->SetEventListener(foreign, |
7682 Utils::OpenHandle(*data, true)); | 7655 Utils::OpenHandle(*data, true)); |
7683 return true; | 7656 return true; |
(...skipping 28 matching lines...) Expand all Loading... |
7712 const uint16_t* command, | 7685 const uint16_t* command, |
7713 int length, | 7686 int length, |
7714 ClientData* client_data) { | 7687 ClientData* client_data) { |
7715 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7688 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7716 internal_isolate->debug()->EnqueueCommandMessage( | 7689 internal_isolate->debug()->EnqueueCommandMessage( |
7717 i::Vector<const uint16_t>(command, length), client_data); | 7690 i::Vector<const uint16_t>(command, length), client_data); |
7718 } | 7691 } |
7719 | 7692 |
7720 | 7693 |
7721 MaybeLocal<Value> Debug::Call(Local<Context> context, | 7694 MaybeLocal<Value> Debug::Call(Local<Context> context, |
7722 v8::Handle<v8::Function> fun, | 7695 v8::Local<v8::Function> fun, |
7723 v8::Handle<v8::Value> data) { | 7696 v8::Local<v8::Value> data) { |
7724 PREPARE_FOR_EXECUTION(context, "v8::Debug::Call()", Value); | 7697 PREPARE_FOR_EXECUTION(context, "v8::Debug::Call()", Value); |
7725 i::Handle<i::Object> data_obj; | 7698 i::Handle<i::Object> data_obj; |
7726 if (data.IsEmpty()) { | 7699 if (data.IsEmpty()) { |
7727 data_obj = isolate->factory()->undefined_value(); | 7700 data_obj = isolate->factory()->undefined_value(); |
7728 } else { | 7701 } else { |
7729 data_obj = Utils::OpenHandle(*data); | 7702 data_obj = Utils::OpenHandle(*data); |
7730 } | 7703 } |
7731 Local<Value> result; | 7704 Local<Value> result; |
7732 has_pending_exception = | 7705 has_pending_exception = |
7733 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), | 7706 !ToLocal<Value>(isolate->debug()->Call(Utils::OpenHandle(*fun), data_obj), |
7734 &result); | 7707 &result); |
7735 RETURN_ON_FAILED_EXECUTION(Value); | 7708 RETURN_ON_FAILED_EXECUTION(Value); |
7736 RETURN_ESCAPED(result); | 7709 RETURN_ESCAPED(result); |
7737 } | 7710 } |
7738 | 7711 |
7739 | 7712 |
7740 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, | 7713 Local<Value> Debug::Call(v8::Local<v8::Function> fun, |
7741 v8::Handle<v8::Value> data) { | 7714 v8::Local<v8::Value> data) { |
7742 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); | 7715 auto context = ContextFromHeapObject(Utils::OpenHandle(*fun)); |
7743 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); | 7716 RETURN_TO_LOCAL_UNCHECKED(Call(context, fun, data), Value); |
7744 } | 7717 } |
7745 | 7718 |
7746 | 7719 |
7747 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, | 7720 MaybeLocal<Value> Debug::GetMirror(Local<Context> context, |
7748 v8::Handle<v8::Value> obj) { | 7721 v8::Local<v8::Value> obj) { |
7749 PREPARE_FOR_EXECUTION(context, "v8::Debug::GetMirror()", Value); | 7722 PREPARE_FOR_EXECUTION(context, "v8::Debug::GetMirror()", Value); |
7750 i::Debug* isolate_debug = isolate->debug(); | 7723 i::Debug* isolate_debug = isolate->debug(); |
7751 has_pending_exception = !isolate_debug->Load(); | 7724 has_pending_exception = !isolate_debug->Load(); |
7752 RETURN_ON_FAILED_EXECUTION(Value); | 7725 RETURN_ON_FAILED_EXECUTION(Value); |
7753 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 7726 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
7754 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); | 7727 auto name = isolate->factory()->NewStringFromStaticChars("MakeMirror"); |
7755 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); | 7728 auto fun_obj = i::Object::GetProperty(debug, name).ToHandleChecked(); |
7756 auto v8_fun = Utils::ToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); | 7729 auto v8_fun = Utils::ToLocal(i::Handle<i::JSFunction>::cast(fun_obj)); |
7757 const int kArgc = 1; | 7730 const int kArgc = 1; |
7758 v8::Handle<v8::Value> argv[kArgc] = {obj}; | 7731 v8::Local<v8::Value> argv[kArgc] = {obj}; |
7759 Local<Value> result; | 7732 Local<Value> result; |
7760 has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, | 7733 has_pending_exception = !v8_fun->Call(context, Utils::ToLocal(debug), kArgc, |
7761 argv).ToLocal(&result); | 7734 argv).ToLocal(&result); |
7762 RETURN_ON_FAILED_EXECUTION(Value); | 7735 RETURN_ON_FAILED_EXECUTION(Value); |
7763 RETURN_ESCAPED(result); | 7736 RETURN_ESCAPED(result); |
7764 } | 7737 } |
7765 | 7738 |
7766 | 7739 |
7767 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { | 7740 Local<Value> Debug::GetMirror(v8::Local<v8::Value> obj) { |
7768 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); | 7741 RETURN_TO_LOCAL_UNCHECKED(GetMirror(Local<Context>(), obj), Value); |
7769 } | 7742 } |
7770 | 7743 |
7771 | 7744 |
7772 void Debug::ProcessDebugMessages() { | 7745 void Debug::ProcessDebugMessages() { |
7773 i::Isolate::Current()->debug()->ProcessDebugMessages(true); | 7746 i::Isolate::Current()->debug()->ProcessDebugMessages(true); |
7774 } | 7747 } |
7775 | 7748 |
7776 | 7749 |
7777 Local<Context> Debug::GetDebugContext() { | 7750 Local<Context> Debug::GetDebugContext() { |
(...skipping 14 matching lines...) Expand all Loading... |
7792 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 7765 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
7793 ENTER_V8(isolate); | 7766 ENTER_V8(isolate); |
7794 i::Handle<i::Object> val = Utils::OpenHandle(*value); | 7767 i::Handle<i::Object> val = Utils::OpenHandle(*value); |
7795 i::Handle<i::JSArray> result; | 7768 i::Handle<i::JSArray> result; |
7796 if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result)) | 7769 if (!i::Runtime::GetInternalProperties(isolate, val).ToHandle(&result)) |
7797 return MaybeLocal<Array>(); | 7770 return MaybeLocal<Array>(); |
7798 return Utils::ToLocal(result); | 7771 return Utils::ToLocal(result); |
7799 } | 7772 } |
7800 | 7773 |
7801 | 7774 |
7802 Handle<String> CpuProfileNode::GetFunctionName() const { | 7775 Local<String> CpuProfileNode::GetFunctionName() const { |
7803 i::Isolate* isolate = i::Isolate::Current(); | 7776 i::Isolate* isolate = i::Isolate::Current(); |
7804 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7777 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7805 const i::CodeEntry* entry = node->entry(); | 7778 const i::CodeEntry* entry = node->entry(); |
7806 i::Handle<i::String> name = | 7779 i::Handle<i::String> name = |
7807 isolate->factory()->InternalizeUtf8String(entry->name()); | 7780 isolate->factory()->InternalizeUtf8String(entry->name()); |
7808 if (!entry->has_name_prefix()) { | 7781 if (!entry->has_name_prefix()) { |
7809 return ToApiHandle<String>(name); | 7782 return ToApiHandle<String>(name); |
7810 } else { | 7783 } else { |
7811 // We do not expect this to fail. Change this if it does. | 7784 // We do not expect this to fail. Change this if it does. |
7812 i::Handle<i::String> cons = isolate->factory()->NewConsString( | 7785 i::Handle<i::String> cons = isolate->factory()->NewConsString( |
7813 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 7786 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
7814 name).ToHandleChecked(); | 7787 name).ToHandleChecked(); |
7815 return ToApiHandle<String>(cons); | 7788 return ToApiHandle<String>(cons); |
7816 } | 7789 } |
7817 } | 7790 } |
7818 | 7791 |
7819 | 7792 |
7820 int CpuProfileNode::GetScriptId() const { | 7793 int CpuProfileNode::GetScriptId() const { |
7821 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7794 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7822 const i::CodeEntry* entry = node->entry(); | 7795 const i::CodeEntry* entry = node->entry(); |
7823 return entry->script_id(); | 7796 return entry->script_id(); |
7824 } | 7797 } |
7825 | 7798 |
7826 | 7799 |
7827 Handle<String> CpuProfileNode::GetScriptResourceName() const { | 7800 Local<String> CpuProfileNode::GetScriptResourceName() const { |
7828 i::Isolate* isolate = i::Isolate::Current(); | 7801 i::Isolate* isolate = i::Isolate::Current(); |
7829 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7802 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
7830 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 7803 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
7831 node->entry()->resource_name())); | 7804 node->entry()->resource_name())); |
7832 } | 7805 } |
7833 | 7806 |
7834 | 7807 |
7835 int CpuProfileNode::GetLineNumber() const { | 7808 int CpuProfileNode::GetLineNumber() const { |
7836 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | 7809 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
7837 } | 7810 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7896 | 7869 |
7897 | 7870 |
7898 void CpuProfile::Delete() { | 7871 void CpuProfile::Delete() { |
7899 i::Isolate* isolate = i::Isolate::Current(); | 7872 i::Isolate* isolate = i::Isolate::Current(); |
7900 i::CpuProfiler* profiler = isolate->cpu_profiler(); | 7873 i::CpuProfiler* profiler = isolate->cpu_profiler(); |
7901 DCHECK(profiler != NULL); | 7874 DCHECK(profiler != NULL); |
7902 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); | 7875 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); |
7903 } | 7876 } |
7904 | 7877 |
7905 | 7878 |
7906 Handle<String> CpuProfile::GetTitle() const { | 7879 Local<String> CpuProfile::GetTitle() const { |
7907 i::Isolate* isolate = i::Isolate::Current(); | 7880 i::Isolate* isolate = i::Isolate::Current(); |
7908 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 7881 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
7909 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( | 7882 return ToApiHandle<String>(isolate->factory()->InternalizeUtf8String( |
7910 profile->title())); | 7883 profile->title())); |
7911 } | 7884 } |
7912 | 7885 |
7913 | 7886 |
7914 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { | 7887 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { |
7915 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 7888 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
7916 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); | 7889 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
(...skipping 30 matching lines...) Expand all Loading... |
7947 } | 7920 } |
7948 | 7921 |
7949 | 7922 |
7950 void CpuProfiler::SetSamplingInterval(int us) { | 7923 void CpuProfiler::SetSamplingInterval(int us) { |
7951 DCHECK(us >= 0); | 7924 DCHECK(us >= 0); |
7952 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( | 7925 return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( |
7953 base::TimeDelta::FromMicroseconds(us)); | 7926 base::TimeDelta::FromMicroseconds(us)); |
7954 } | 7927 } |
7955 | 7928 |
7956 | 7929 |
7957 void CpuProfiler::StartProfiling(Handle<String> title, bool record_samples) { | 7930 void CpuProfiler::StartProfiling(Local<String> title, bool record_samples) { |
7958 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( | 7931 reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( |
7959 *Utils::OpenHandle(*title), record_samples); | 7932 *Utils::OpenHandle(*title), record_samples); |
7960 } | 7933 } |
7961 | 7934 |
7962 | 7935 |
7963 CpuProfile* CpuProfiler::StopProfiling(Handle<String> title) { | 7936 CpuProfile* CpuProfiler::StopProfiling(Local<String> title) { |
7964 return reinterpret_cast<CpuProfile*>( | 7937 return reinterpret_cast<CpuProfile*>( |
7965 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( | 7938 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( |
7966 *Utils::OpenHandle(*title))); | 7939 *Utils::OpenHandle(*title))); |
7967 } | 7940 } |
7968 | 7941 |
7969 | 7942 |
7970 void CpuProfiler::SetIdle(bool is_idle) { | 7943 void CpuProfiler::SetIdle(bool is_idle) { |
7971 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); | 7944 i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); |
7972 v8::StateTag state = isolate->current_vm_state(); | 7945 v8::StateTag state = isolate->current_vm_state(); |
7973 DCHECK(state == v8::EXTERNAL || state == v8::IDLE); | 7946 DCHECK(state == v8::EXTERNAL || state == v8::IDLE); |
(...skipping 10 matching lines...) Expand all Loading... |
7984 return const_cast<i::HeapGraphEdge*>( | 7957 return const_cast<i::HeapGraphEdge*>( |
7985 reinterpret_cast<const i::HeapGraphEdge*>(edge)); | 7958 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
7986 } | 7959 } |
7987 | 7960 |
7988 | 7961 |
7989 HeapGraphEdge::Type HeapGraphEdge::GetType() const { | 7962 HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
7990 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); | 7963 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); |
7991 } | 7964 } |
7992 | 7965 |
7993 | 7966 |
7994 Handle<Value> HeapGraphEdge::GetName() const { | 7967 Local<Value> HeapGraphEdge::GetName() const { |
7995 i::Isolate* isolate = i::Isolate::Current(); | 7968 i::Isolate* isolate = i::Isolate::Current(); |
7996 i::HeapGraphEdge* edge = ToInternal(this); | 7969 i::HeapGraphEdge* edge = ToInternal(this); |
7997 switch (edge->type()) { | 7970 switch (edge->type()) { |
7998 case i::HeapGraphEdge::kContextVariable: | 7971 case i::HeapGraphEdge::kContextVariable: |
7999 case i::HeapGraphEdge::kInternal: | 7972 case i::HeapGraphEdge::kInternal: |
8000 case i::HeapGraphEdge::kProperty: | 7973 case i::HeapGraphEdge::kProperty: |
8001 case i::HeapGraphEdge::kShortcut: | 7974 case i::HeapGraphEdge::kShortcut: |
8002 case i::HeapGraphEdge::kWeak: | 7975 case i::HeapGraphEdge::kWeak: |
8003 return ToApiHandle<String>( | 7976 return ToApiHandle<String>( |
8004 isolate->factory()->InternalizeUtf8String(edge->name())); | 7977 isolate->factory()->InternalizeUtf8String(edge->name())); |
(...skipping 23 matching lines...) Expand all Loading... |
8028 return const_cast<i::HeapEntry*>( | 8001 return const_cast<i::HeapEntry*>( |
8029 reinterpret_cast<const i::HeapEntry*>(entry)); | 8002 reinterpret_cast<const i::HeapEntry*>(entry)); |
8030 } | 8003 } |
8031 | 8004 |
8032 | 8005 |
8033 HeapGraphNode::Type HeapGraphNode::GetType() const { | 8006 HeapGraphNode::Type HeapGraphNode::GetType() const { |
8034 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); | 8007 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); |
8035 } | 8008 } |
8036 | 8009 |
8037 | 8010 |
8038 Handle<String> HeapGraphNode::GetName() const { | 8011 Local<String> HeapGraphNode::GetName() const { |
8039 i::Isolate* isolate = i::Isolate::Current(); | 8012 i::Isolate* isolate = i::Isolate::Current(); |
8040 return ToApiHandle<String>( | 8013 return ToApiHandle<String>( |
8041 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name())); | 8014 isolate->factory()->InternalizeUtf8String(ToInternal(this)->name())); |
8042 } | 8015 } |
8043 | 8016 |
8044 | 8017 |
8045 SnapshotObjectId HeapGraphNode::GetId() const { | 8018 SnapshotObjectId HeapGraphNode::GetId() const { |
8046 return ToInternal(this)->id(); | 8019 return ToInternal(this)->id(); |
8047 } | 8020 } |
8048 | 8021 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8129 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); | 8102 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotsCount(); |
8130 } | 8103 } |
8131 | 8104 |
8132 | 8105 |
8133 const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) { | 8106 const HeapSnapshot* HeapProfiler::GetHeapSnapshot(int index) { |
8134 return reinterpret_cast<const HeapSnapshot*>( | 8107 return reinterpret_cast<const HeapSnapshot*>( |
8135 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); | 8108 reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshot(index)); |
8136 } | 8109 } |
8137 | 8110 |
8138 | 8111 |
8139 SnapshotObjectId HeapProfiler::GetObjectId(Handle<Value> value) { | 8112 SnapshotObjectId HeapProfiler::GetObjectId(Local<Value> value) { |
8140 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 8113 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
8141 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj); | 8114 return reinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj); |
8142 } | 8115 } |
8143 | 8116 |
8144 | 8117 |
8145 Handle<Value> HeapProfiler::FindObjectById(SnapshotObjectId id) { | 8118 Local<Value> HeapProfiler::FindObjectById(SnapshotObjectId id) { |
8146 i::Handle<i::Object> obj = | 8119 i::Handle<i::Object> obj = |
8147 reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id); | 8120 reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id); |
8148 if (obj.is_null()) return Local<Value>(); | 8121 if (obj.is_null()) return Local<Value>(); |
8149 return Utils::ToLocal(obj); | 8122 return Utils::ToLocal(obj); |
8150 } | 8123 } |
8151 | 8124 |
8152 | 8125 |
8153 void HeapProfiler::ClearObjectIds() { | 8126 void HeapProfiler::ClearObjectIds() { |
8154 reinterpret_cast<i::HeapProfiler*>(this)->ClearHeapObjectMap(); | 8127 reinterpret_cast<i::HeapProfiler*>(this)->ClearHeapObjectMap(); |
8155 } | 8128 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8438 Address callback_address = | 8411 Address callback_address = |
8439 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8412 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8440 VMState<EXTERNAL> state(isolate); | 8413 VMState<EXTERNAL> state(isolate); |
8441 ExternalCallbackScope call_scope(isolate, callback_address); | 8414 ExternalCallbackScope call_scope(isolate, callback_address); |
8442 callback(info); | 8415 callback(info); |
8443 } | 8416 } |
8444 | 8417 |
8445 | 8418 |
8446 } // namespace internal | 8419 } // namespace internal |
8447 } // namespace v8 | 8420 } // namespace v8 |
OLD | NEW |