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 |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 if (IsHeapNumber()) { | 981 if (IsHeapNumber()) { |
982 double num = HeapNumber::cast(this)->value(); | 982 double num = HeapNumber::cast(this)->value(); |
983 if (FastI2D(FastD2I(num)) == num) { | 983 if (FastI2D(FastD2I(num)) == num) { |
984 *value = FastD2I(num); | 984 *value = FastD2I(num); |
985 return true; | 985 return true; |
986 } | 986 } |
987 } | 987 } |
988 return false; | 988 return false; |
989 } | 989 } |
990 | 990 |
991 bool FunctionTemplateInfo::IsTemplateFor(JSObject* object) { | |
992 return IsTemplateFor(object->map()); | |
993 } | |
994 | |
995 | |
996 bool FunctionTemplateInfo::IsTemplateFor(Map* map) { | 991 bool FunctionTemplateInfo::IsTemplateFor(Map* map) { |
997 // There is a constraint on the object; check. | 992 // There is a constraint on the object; check. |
998 if (!map->IsJSObjectMap()) return false; | 993 if (!map->IsJSObjectMap()) return false; |
999 // Fetch the constructor function of the object. | 994 // Fetch the constructor function of the object. |
1000 Object* cons_obj = map->GetConstructor(); | 995 Object* cons_obj = map->GetConstructor(); |
1001 if (!cons_obj->IsJSFunction()) return false; | 996 if (!cons_obj->IsJSFunction()) return false; |
1002 JSFunction* fun = JSFunction::cast(cons_obj); | 997 JSFunction* fun = JSFunction::cast(cons_obj); |
1003 // Iterate through the chain of inheriting function templates to | 998 // Iterate through the chain of inheriting function templates to |
1004 // see if the required one occurs. | 999 // see if the required one occurs. |
1005 for (Object* type = fun->shared()->function_data(); | 1000 for (Object* type = fun->shared()->function_data(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 Handle<Object> result = args.Call(call_fun, name); | 1144 Handle<Object> result = args.Call(call_fun, name); |
1150 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); | 1145 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); |
1151 if (result.is_null()) return ReadAbsentProperty(isolate, receiver, name); | 1146 if (result.is_null()) return ReadAbsentProperty(isolate, receiver, name); |
1152 // Rebox handle before return. | 1147 // Rebox handle before return. |
1153 return handle(*result, isolate); | 1148 return handle(*result, isolate); |
1154 } | 1149 } |
1155 | 1150 |
1156 // Regular accessor. | 1151 // Regular accessor. |
1157 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); | 1152 Handle<Object> getter(AccessorPair::cast(*structure)->getter(), isolate); |
1158 if (getter->IsFunctionTemplateInfo()) { | 1153 if (getter->IsFunctionTemplateInfo()) { |
1159 auto result = Builtins::InvokeApiFunction( | 1154 return Builtins::InvokeApiFunction( |
1160 Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, nullptr); | 1155 isolate, Handle<FunctionTemplateInfo>::cast(getter), receiver, 0, |
1161 if (isolate->has_pending_exception()) { | 1156 nullptr); |
1162 return MaybeHandle<Object>(); | |
1163 } | |
1164 Handle<Object> return_value; | |
1165 if (result.ToHandle(&return_value)) { | |
1166 return_value->VerifyApiCallResultType(); | |
1167 return handle(*return_value, isolate); | |
1168 } | |
1169 } else if (getter->IsCallable()) { | 1157 } else if (getter->IsCallable()) { |
1170 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1158 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
1171 return Object::GetPropertyWithDefinedGetter( | 1159 return Object::GetPropertyWithDefinedGetter( |
1172 receiver, Handle<JSReceiver>::cast(getter)); | 1160 receiver, Handle<JSReceiver>::cast(getter)); |
1173 } | 1161 } |
1174 // Getter is not a function. | 1162 // Getter is not a function. |
1175 return ReadAbsentProperty(isolate, receiver, it->GetName()); | 1163 return ReadAbsentProperty(isolate, receiver, it->GetName()); |
1176 } | 1164 } |
1177 | 1165 |
1178 // static | 1166 // static |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 should_throw); | 1226 should_throw); |
1239 args.Call(call_fun, name, value); | 1227 args.Call(call_fun, name, value); |
1240 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); | 1228 RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Nothing<bool>()); |
1241 return Just(true); | 1229 return Just(true); |
1242 } | 1230 } |
1243 | 1231 |
1244 // Regular accessor. | 1232 // Regular accessor. |
1245 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); | 1233 Handle<Object> setter(AccessorPair::cast(*structure)->setter(), isolate); |
1246 if (setter->IsFunctionTemplateInfo()) { | 1234 if (setter->IsFunctionTemplateInfo()) { |
1247 Handle<Object> argv[] = {value}; | 1235 Handle<Object> argv[] = {value}; |
1248 auto result = | 1236 RETURN_ON_EXCEPTION_VALUE( |
1249 Builtins::InvokeApiFunction(Handle<FunctionTemplateInfo>::cast(setter), | 1237 isolate, Builtins::InvokeApiFunction( |
1250 receiver, arraysize(argv), argv); | 1238 isolate, Handle<FunctionTemplateInfo>::cast(setter), |
1251 if (isolate->has_pending_exception()) { | 1239 receiver, arraysize(argv), argv), |
1252 return Nothing<bool>(); | 1240 Nothing<bool>()); |
1253 } | |
1254 return Just(true); | 1241 return Just(true); |
1255 } else if (setter->IsCallable()) { | 1242 } else if (setter->IsCallable()) { |
1256 // TODO(rossberg): nicer would be to cast to some JSCallable here... | 1243 // TODO(rossberg): nicer would be to cast to some JSCallable here... |
1257 return SetPropertyWithDefinedSetter( | 1244 return SetPropertyWithDefinedSetter( |
1258 receiver, Handle<JSReceiver>::cast(setter), value, should_throw); | 1245 receiver, Handle<JSReceiver>::cast(setter), value, should_throw); |
1259 } | 1246 } |
1260 | 1247 |
1261 RETURN_FAILURE(isolate, should_throw, | 1248 RETURN_FAILURE(isolate, should_throw, |
1262 NewTypeError(MessageTemplate::kNoSetterInCallback, | 1249 NewTypeError(MessageTemplate::kNoSetterInCallback, |
1263 it->GetName(), it->GetHolder<JSObject>())); | 1250 it->GetName(), it->GetHolder<JSObject>())); |
(...skipping 17604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18868 } else { | 18855 } else { |
18869 // Old-style generators. | 18856 // Old-style generators. |
18870 int offset = continuation(); | 18857 int offset = continuation(); |
18871 CHECK(0 <= offset && offset < function()->code()->instruction_size()); | 18858 CHECK(0 <= offset && offset < function()->code()->instruction_size()); |
18872 return function()->code()->SourcePosition(offset); | 18859 return function()->code()->SourcePosition(offset); |
18873 } | 18860 } |
18874 } | 18861 } |
18875 | 18862 |
18876 } // namespace internal | 18863 } // namespace internal |
18877 } // namespace v8 | 18864 } // namespace v8 |
OLD | NEW |