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

Side by Side Diff: src/builtins.cc

Issue 238973003: Handlify Object::GetPrototype and (most) callers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Minor Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/handles.cc » ('j') | src/ic.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 } 1102 }
1103 1103
1104 1104
1105 // ----------------------------------------------------------------------------- 1105 // -----------------------------------------------------------------------------
1106 // 1106 //
1107 1107
1108 1108
1109 // Searches the hidden prototype chain of the given object for the first 1109 // Searches the hidden prototype chain of the given object for the first
1110 // object that is an instance of the given type. If no such object can 1110 // object that is an instance of the given type. If no such object can
1111 // be found then Heap::null_value() is returned. 1111 // be found then Heap::null_value() is returned.
1112 static inline Object* FindHidden(Heap* heap, 1112 static inline Handle<Object> FindHidden(Isolate* isolate,
1113 Object* object, 1113 Handle<Object> object,
1114 FunctionTemplateInfo* type) { 1114 Handle<FunctionTemplateInfo> type) {
Yang 2014/04/15 13:10:48 It seems like we don't need to handlify this and i
1115 if (type->IsTemplateFor(object)) return object; 1115 if (type->IsTemplateFor(*object)) return object;
1116 Object* proto = object->GetPrototype(heap->isolate()); 1116 Handle<Object> proto = Object::GetPrototype(isolate, object);
1117 if (proto->IsJSObject() && 1117 if (proto->IsJSObject() &&
1118 JSObject::cast(proto)->map()->is_hidden_prototype()) { 1118 JSObject::cast(*proto)->map()->is_hidden_prototype()) {
1119 return FindHidden(heap, proto, type); 1119 return FindHidden(isolate, proto, type);
1120 } 1120 }
1121 return heap->null_value(); 1121 return Handle<Object>();
1122 } 1122 }
1123 1123
1124 1124
1125 // Returns the holder JSObject if the function can legally be called 1125 // Returns the holder JSObject if the function can legally be called
1126 // with this receiver. Returns Heap::null_value() if the call is 1126 // with this receiver. Returns Heap::null_value() if the call is
1127 // illegal. Any arguments that don't fit the expected type is 1127 // illegal. Any arguments that don't fit the expected type is
1128 // overwritten with undefined. Note that holder and the arguments are 1128 // overwritten with undefined. Note that holder and the arguments are
1129 // implicitly rewritten with the first object in the hidden prototype 1129 // implicitly rewritten with the first object in the hidden prototype
1130 // chain that actually has the expected type. 1130 // chain that actually has the expected type.
1131 static inline Object* TypeCheck(Heap* heap, 1131 static inline Object* TypeCheck(Heap* heap,
1132 int argc, 1132 int argc,
1133 Object** argv, 1133 Object** argv,
1134 FunctionTemplateInfo* info) { 1134 FunctionTemplateInfo* info) {
1135 Isolate* isolate = heap->isolate();
1136 HandleScope scope(isolate);
1137 DisallowHeapAllocation no_alloc;
1135 Object* recv = argv[0]; 1138 Object* recv = argv[0];
1136 // API calls are only supported with JSObject receivers. 1139 // API calls are only supported with JSObject receivers.
1137 if (!recv->IsJSObject()) return heap->null_value(); 1140 if (!recv->IsJSObject()) return heap->null_value();
1138 Object* sig_obj = info->signature(); 1141 Object* sig_obj = info->signature();
1139 if (sig_obj->IsUndefined()) return recv; 1142 if (sig_obj->IsUndefined()) return recv;
1140 SignatureInfo* sig = SignatureInfo::cast(sig_obj); 1143 SignatureInfo* sig = SignatureInfo::cast(sig_obj);
1141 // If necessary, check the receiver 1144 // If necessary, check the receiver
1142 Object* recv_type = sig->receiver(); 1145 Object* recv_type = sig->receiver();
1143 Object* holder = recv; 1146 Object* holder = recv;
1144 if (!recv_type->IsUndefined()) { 1147 if (!recv_type->IsUndefined()) {
1145 holder = FindHidden(heap, holder, FunctionTemplateInfo::cast(recv_type)); 1148 Handle<Object> hidden =
1146 if (holder == heap->null_value()) return heap->null_value(); 1149 FindHidden(
1150 isolate,
1151 handle(holder, isolate),
1152 handle(FunctionTemplateInfo::cast(recv_type)));
1153 if (hidden.is_null()) return heap->null_value();
1154 holder = *hidden;
1147 } 1155 }
1148 Object* args_obj = sig->args(); 1156 Object* args_obj = sig->args();
1149 // If there is no argument signature we're done 1157 // If there is no argument signature we're done
1150 if (args_obj->IsUndefined()) return holder; 1158 if (args_obj->IsUndefined()) return holder;
1151 FixedArray* args = FixedArray::cast(args_obj); 1159 FixedArray* args = FixedArray::cast(args_obj);
1152 int length = args->length(); 1160 int length = args->length();
1153 if (argc <= length) length = argc - 1; 1161 if (argc <= length) length = argc - 1;
1154 for (int i = 0; i < length; i++) { 1162 for (int i = 0; i < length; i++) {
1155 Object* argtype = args->get(i); 1163 Object* argtype = args->get(i);
1156 if (argtype->IsUndefined()) continue; 1164 if (argtype->IsUndefined()) continue;
1157 Object** arg = &argv[-1 - i]; 1165 Object** arg = &argv[-1 - i];
1158 Object* current = *arg; 1166 Handle<Object> current(*arg, isolate);
1159 current = FindHidden(heap, current, FunctionTemplateInfo::cast(argtype)); 1167 current = FindHidden(
1160 if (current == heap->null_value()) current = heap->undefined_value(); 1168 isolate, current, handle(FunctionTemplateInfo::cast(argtype)));
1161 *arg = current; 1169 if (!current.is_null()) {
1170 *arg = *current;
1171 } else {
1172 *arg = heap->undefined_value();
1173 }
1162 } 1174 }
1163 return holder; 1175 return holder;
1164 } 1176 }
1165 1177
1166 1178
1167 template <bool is_construct> 1179 template <bool is_construct>
1168 MUST_USE_RESULT static MaybeObject* HandleApiCallHelper( 1180 MUST_USE_RESULT static MaybeObject* HandleApiCallHelper(
1169 BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) { 1181 BuiltinArguments<NEEDS_CALLED_FUNCTION> args, Isolate* isolate) {
1170 ASSERT(is_construct == CalledAsConstructor(isolate)); 1182 ASSERT(is_construct == CalledAsConstructor(isolate));
1171 Heap* heap = isolate->heap(); 1183 Heap* heap = isolate->heap();
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 } 1760 }
1749 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1761 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1750 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1762 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1751 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1763 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1752 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1764 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1753 #undef DEFINE_BUILTIN_ACCESSOR_C 1765 #undef DEFINE_BUILTIN_ACCESSOR_C
1754 #undef DEFINE_BUILTIN_ACCESSOR_A 1766 #undef DEFINE_BUILTIN_ACCESSOR_A
1755 1767
1756 1768
1757 } } // namespace v8::internal 1769 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/handles.cc » ('j') | src/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698