Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/objects.cc

Issue 2084923003: Optimize HandleApiCallHelper and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 991 bool FunctionTemplateInfo::IsTemplateFor(JSObject* object) {
992 bool FunctionTemplateInfo::IsTemplateFor(Object* object) { 992 return IsTemplateFor(object->map());
993 if (!object->IsHeapObject()) return false;
994 return IsTemplateFor(HeapObject::cast(object)->map());
995 } 993 }
996 994
997 995
998 bool FunctionTemplateInfo::IsTemplateFor(Map* map) { 996 bool FunctionTemplateInfo::IsTemplateFor(Map* map) {
999 // There is a constraint on the object; check. 997 // There is a constraint on the object; check.
1000 if (!map->IsJSObjectMap()) return false; 998 if (!map->IsJSObjectMap()) return false;
1001 // Fetch the constructor function of the object. 999 // Fetch the constructor function of the object.
1002 Object* cons_obj = map->GetConstructor(); 1000 Object* cons_obj = map->GetConstructor();
1003 if (!cons_obj->IsJSFunction()) return false; 1001 if (!cons_obj->IsJSFunction()) return false;
1004 JSFunction* fun = JSFunction::cast(cons_obj); 1002 JSFunction* fun = JSFunction::cast(cons_obj);
1005 // Iterate through the chain of inheriting function templates to 1003 // Iterate through the chain of inheriting function templates to
1006 // see if the required one occurs. 1004 // see if the required one occurs.
1007 for (Object* type = fun->shared()->function_data(); 1005 for (Object* type = fun->shared()->function_data();
1008 type->IsFunctionTemplateInfo(); 1006 type->IsFunctionTemplateInfo();
1009 type = FunctionTemplateInfo::cast(type)->parent_template()) { 1007 type = FunctionTemplateInfo::cast(type)->parent_template()) {
1010 if (type == this) return true; 1008 if (type == this) return true;
1011 } 1009 }
1012 // Didn't find the required type in the inheritance chain. 1010 // Didn't find the required type in the inheritance chain.
1013 return false; 1011 return false;
1014 } 1012 }
1015 1013
1016 1014
1017 // TODO(dcarney): CallOptimization duplicates this logic, merge.
1018 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate,
1019 Object* receiver) {
1020 // API calls are only supported with JSObject receivers.
1021 if (!receiver->IsJSObject()) return isolate->heap()->null_value();
1022 Object* recv_type = this->signature();
1023 // No signature, return holder.
1024 if (recv_type->IsUndefined(isolate)) return receiver;
1025 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
1026 // Check the receiver.
1027 for (PrototypeIterator iter(isolate, JSObject::cast(receiver),
1028 kStartAtReceiver,
1029 PrototypeIterator::END_AT_NON_HIDDEN);
1030 !iter.IsAtEnd(); iter.Advance()) {
1031 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent();
1032 }
1033 return isolate->heap()->null_value();
1034 }
1035
1036
1037 // static 1015 // static
1038 MaybeHandle<JSObject> JSObject::New(Handle<JSFunction> constructor, 1016 MaybeHandle<JSObject> JSObject::New(Handle<JSFunction> constructor,
1039 Handle<JSReceiver> new_target, 1017 Handle<JSReceiver> new_target,
1040 Handle<AllocationSite> site) { 1018 Handle<AllocationSite> site) {
1041 // If called through new, new.target can be: 1019 // If called through new, new.target can be:
1042 // - a subclass of constructor, 1020 // - a subclass of constructor,
1043 // - a proxy wrapper around constructor, or 1021 // - a proxy wrapper around constructor, or
1044 // - the constructor itself. 1022 // - the constructor itself.
1045 // If called through Reflect.construct, it's guaranteed to be a constructor. 1023 // If called through Reflect.construct, it's guaranteed to be a constructor.
1046 Isolate* const isolate = constructor->GetIsolate(); 1024 Isolate* const isolate = constructor->GetIsolate();
(...skipping 17811 matching lines...) Expand 10 before | Expand all | Expand 10 after
18858 if (cell->value() != *new_value) { 18836 if (cell->value() != *new_value) {
18859 cell->set_value(*new_value); 18837 cell->set_value(*new_value);
18860 Isolate* isolate = cell->GetIsolate(); 18838 Isolate* isolate = cell->GetIsolate();
18861 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18839 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18862 isolate, DependentCode::kPropertyCellChangedGroup); 18840 isolate, DependentCode::kPropertyCellChangedGroup);
18863 } 18841 }
18864 } 18842 }
18865 18843
18866 } // namespace internal 18844 } // namespace internal
18867 } // namespace v8 18845 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698