| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| 11 #include "src/accessors.h" | 11 #include "src/accessors.h" |
| 12 #include "src/allocation-site-scopes.h" | 12 #include "src/allocation-site-scopes.h" |
| 13 #include "src/api.h" | 13 #include "src/api.h" |
| 14 #include "src/api-natives.h" | |
| 15 #include "src/arguments.h" | 14 #include "src/arguments.h" |
| 16 #include "src/base/bits.h" | 15 #include "src/base/bits.h" |
| 17 #include "src/base/utils/random-number-generator.h" | 16 #include "src/base/utils/random-number-generator.h" |
| 18 #include "src/bootstrapper.h" | 17 #include "src/bootstrapper.h" |
| 19 #include "src/code-stubs.h" | 18 #include "src/code-stubs.h" |
| 20 #include "src/codegen.h" | 19 #include "src/codegen.h" |
| 21 #include "src/compilation-dependencies.h" | 20 #include "src/compilation-dependencies.h" |
| 22 #include "src/compiler.h" | 21 #include "src/compiler.h" |
| 23 #include "src/date.h" | 22 #include "src/date.h" |
| 24 #include "src/debug/debug.h" | 23 #include "src/debug/debug.h" |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 return ReadAbsentProperty(isolate, receiver, name, language_mode); | 1168 return ReadAbsentProperty(isolate, receiver, name, language_mode); |
| 1170 } | 1169 } |
| 1171 Handle<Object> return_value = v8::Utils::OpenHandle(*result); | 1170 Handle<Object> return_value = v8::Utils::OpenHandle(*result); |
| 1172 return_value->VerifyApiCallResultType(); | 1171 return_value->VerifyApiCallResultType(); |
| 1173 // Rebox handle before return. | 1172 // Rebox handle before return. |
| 1174 return handle(*return_value, isolate); | 1173 return handle(*return_value, isolate); |
| 1175 } | 1174 } |
| 1176 | 1175 |
| 1177 // Regular accessor. | 1176 // Regular accessor. |
| 1178 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); | 1177 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); |
| 1179 if (getter->IsFunctionTemplateInfo()) { | 1178 if (getter->IsCallable()) { |
| 1180 auto result = Builtins::InvokeApiFunction( | |
| 1181 Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, nullptr); | |
| 1182 if (isolate->has_pending_exception()) { | |
| 1183 return MaybeHandle<Object>(); | |
| 1184 } | |
| 1185 Handle<Object> return_value; | |
| 1186 if (result.ToHandle(&return_value)) { | |
| 1187 return_value->VerifyApiCallResultType(); | |
| 1188 return handle(*return_value, isolate); | |
| 1189 } | |
| 1190 } else if (getter->IsCallable()) { | |
| 1191 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1179 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 1192 return Object::GetPropertyWithDefinedGetter( | 1180 return Object::GetPropertyWithDefinedGetter( |
| 1193 receiver, Handle<JSReceiver>::cast(getter)); | 1181 receiver, Handle<JSReceiver>::cast(getter)); |
| 1194 } | 1182 } |
| 1195 // Getter is not a function. | 1183 // Getter is not a function. |
| 1196 return ReadAbsentProperty(isolate, receiver, it->GetName(), language_mode); | 1184 return ReadAbsentProperty(isolate, receiver, it->GetName(), language_mode); |
| 1197 } | 1185 } |
| 1198 | 1186 |
| 1199 | 1187 |
| 1200 bool AccessorInfo::IsCompatibleReceiverMap(Isolate* isolate, | 1188 bool AccessorInfo::IsCompatibleReceiverMap(Isolate* isolate, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); | 1226 LOG(isolate, ApiNamedPropertyAccess("store", *holder, *name)); |
| 1239 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder, | 1227 PropertyCallbackArguments args(isolate, info->data(), *receiver, *holder, |
| 1240 should_throw); | 1228 should_throw); |
| 1241 args.Call(call_fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); | 1229 args.Call(call_fun, v8::Utils::ToLocal(name), v8::Utils::ToLocal(value)); |
| 1242 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 1230 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); |
| 1243 return Just(true); | 1231 return Just(true); |
| 1244 } | 1232 } |
| 1245 | 1233 |
| 1246 // Regular accessor. | 1234 // Regular accessor. |
| 1247 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 1235 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
| 1248 if (setter->IsFunctionTemplateInfo()) { | 1236 if (setter->IsCallable()) { |
| 1249 Handle<Object> argv[] = {value}; | |
| 1250 auto result = | |
| 1251 Builtins::InvokeApiFunction(Handle<FunctionTemplateInfo>::cast(setter), | |
| 1252 receiver, arraysize(argv), argv); | |
| 1253 if (isolate->has_pending_exception()) { | |
| 1254 return Nothing<bool>(); | |
| 1255 } | |
| 1256 return Just(true); | |
| 1257 } else if (setter->IsCallable()) { | |
| 1258 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1237 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
| 1259 return SetPropertyWithDefinedSetter( | 1238 return SetPropertyWithDefinedSetter( |
| 1260 receiver, Handle<JSReceiver>::cast(setter), value, should_throw); | 1239 receiver, Handle<JSReceiver>::cast(setter), value, should_throw); |
| 1261 } | 1240 } |
| 1262 | 1241 |
| 1263 RETURN_FAILURE(isolate, should_throw, | 1242 RETURN_FAILURE(isolate, should_throw, |
| 1264 NewTypeError(MessageTemplate::kNoSetterInCallback, | 1243 NewTypeError(MessageTemplate::kNoSetterInCallback, |
| 1265 it->GetName(), it->GetHolder<JSObject>())); | 1244 it->GetName(), it->GetHolder<JSObject>())); |
| 1266 } | 1245 } |
| 1267 | 1246 |
| (...skipping 7811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9079 bool preexists = false; | 9058 bool preexists = false; |
| 9080 if (is_observed) { | 9059 if (is_observed) { |
| 9081 CHECK(GetPropertyAttributes(it).IsJust()); | 9060 CHECK(GetPropertyAttributes(it).IsJust()); |
| 9082 preexists = it->IsFound(); | 9061 preexists = it->IsFound(); |
| 9083 if (preexists && (it->state() == LookupIterator::DATA || | 9062 if (preexists && (it->state() == LookupIterator::DATA || |
| 9084 it->GetAccessors()->IsAccessorInfo())) { | 9063 it->GetAccessors()->IsAccessorInfo())) { |
| 9085 old_value = GetProperty(it).ToHandleChecked(); | 9064 old_value = GetProperty(it).ToHandleChecked(); |
| 9086 } | 9065 } |
| 9087 } | 9066 } |
| 9088 | 9067 |
| 9089 DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull() || | 9068 DCHECK(getter->IsCallable() || getter->IsUndefined() || getter->IsNull()); |
| 9090 getter->IsFunctionTemplateInfo()); | 9069 DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull()); |
| 9091 DCHECK(setter->IsCallable() || setter->IsUndefined() || setter->IsNull() || | |
| 9092 getter->IsFunctionTemplateInfo()); | |
| 9093 // At least one of the accessors needs to be a new value. | 9070 // At least one of the accessors needs to be a new value. |
| 9094 DCHECK(!getter->IsNull() || !setter->IsNull()); | 9071 DCHECK(!getter->IsNull() || !setter->IsNull()); |
| 9095 if (!getter->IsNull()) { | 9072 if (!getter->IsNull()) { |
| 9096 it->TransitionToAccessorProperty(ACCESSOR_GETTER, getter, attributes); | 9073 it->TransitionToAccessorProperty(ACCESSOR_GETTER, getter, attributes); |
| 9097 } | 9074 } |
| 9098 if (!setter->IsNull()) { | 9075 if (!setter->IsNull()) { |
| 9099 it->TransitionToAccessorProperty(ACCESSOR_SETTER, setter, attributes); | 9076 it->TransitionToAccessorProperty(ACCESSOR_SETTER, setter, attributes); |
| 9100 } | 9077 } |
| 9101 | 9078 |
| 9102 if (is_observed) { | 9079 if (is_observed) { |
| (...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10997 Handle<AccessorPair> AccessorPair::Copy(Handle<AccessorPair> pair) { | 10974 Handle<AccessorPair> AccessorPair::Copy(Handle<AccessorPair> pair) { |
| 10998 Handle<AccessorPair> copy = pair->GetIsolate()->factory()->NewAccessorPair(); | 10975 Handle<AccessorPair> copy = pair->GetIsolate()->factory()->NewAccessorPair(); |
| 10999 copy->set_getter(pair->getter()); | 10976 copy->set_getter(pair->getter()); |
| 11000 copy->set_setter(pair->setter()); | 10977 copy->set_setter(pair->setter()); |
| 11001 return copy; | 10978 return copy; |
| 11002 } | 10979 } |
| 11003 | 10980 |
| 11004 | 10981 |
| 11005 Object* AccessorPair::GetComponent(AccessorComponent component) { | 10982 Object* AccessorPair::GetComponent(AccessorComponent component) { |
| 11006 Object* accessor = get(component); | 10983 Object* accessor = get(component); |
| 11007 if (accessor->IsFunctionTemplateInfo()) { | |
| 11008 return *ApiNatives::InstantiateFunction( | |
| 11009 handle(FunctionTemplateInfo::cast(accessor))) | |
| 11010 .ToHandleChecked(); | |
| 11011 } | |
| 11012 return accessor->IsTheHole() ? GetHeap()->undefined_value() : accessor; | 10984 return accessor->IsTheHole() ? GetHeap()->undefined_value() : accessor; |
| 11013 } | 10985 } |
| 11014 | 10986 |
| 10987 |
| 11015 Handle<DeoptimizationInputData> DeoptimizationInputData::New( | 10988 Handle<DeoptimizationInputData> DeoptimizationInputData::New( |
| 11016 Isolate* isolate, int deopt_entry_count, PretenureFlag pretenure) { | 10989 Isolate* isolate, int deopt_entry_count, PretenureFlag pretenure) { |
| 11017 return Handle<DeoptimizationInputData>::cast( | 10990 return Handle<DeoptimizationInputData>::cast( |
| 11018 isolate->factory()->NewFixedArray(LengthFor(deopt_entry_count), | 10991 isolate->factory()->NewFixedArray(LengthFor(deopt_entry_count), |
| 11019 pretenure)); | 10992 pretenure)); |
| 11020 } | 10993 } |
| 11021 | 10994 |
| 11022 | 10995 |
| 11023 Handle<DeoptimizationOutputData> DeoptimizationOutputData::New( | 10996 Handle<DeoptimizationOutputData> DeoptimizationOutputData::New( |
| 11024 Isolate* isolate, | 10997 Isolate* isolate, |
| (...skipping 8848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19873 if (cell->value() != *new_value) { | 19846 if (cell->value() != *new_value) { |
| 19874 cell->set_value(*new_value); | 19847 cell->set_value(*new_value); |
| 19875 Isolate* isolate = cell->GetIsolate(); | 19848 Isolate* isolate = cell->GetIsolate(); |
| 19876 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19849 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19877 isolate, DependentCode::kPropertyCellChangedGroup); | 19850 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19878 } | 19851 } |
| 19879 } | 19852 } |
| 19880 | 19853 |
| 19881 } // namespace internal | 19854 } // namespace internal |
| 19882 } // namespace v8 | 19855 } // namespace v8 |
| OLD | NEW |