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

Side by Side Diff: src/objects.cc

Issue 873623002: cleanup check for compatible receiver of api callback (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 for (Object* type = fun->shared()->function_data(); 227 for (Object* type = fun->shared()->function_data();
228 type->IsFunctionTemplateInfo(); 228 type->IsFunctionTemplateInfo();
229 type = FunctionTemplateInfo::cast(type)->parent_template()) { 229 type = FunctionTemplateInfo::cast(type)->parent_template()) {
230 if (type == this) return true; 230 if (type == this) return true;
231 } 231 }
232 // Didn't find the required type in the inheritance chain. 232 // Didn't find the required type in the inheritance chain.
233 return false; 233 return false;
234 } 234 }
235 235
236 236
237 // TODO(dcarney): CallOptimization duplicates this logic, merge.
238 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate,
239 Object* receiver) {
240 // API calls are only supported with JSObject receivers.
241 if (!receiver->IsJSObject()) return isolate->heap()->null_value();
242 Object* recv_type = this->signature();
243 // No signature, return holder.
244 if (recv_type->IsUndefined()) return receiver;
245 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
246 // Check the receiver.
247 for (PrototypeIterator iter(isolate, receiver,
248 PrototypeIterator::START_AT_RECEIVER);
249 !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
250 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent();
251 }
252 return isolate->heap()->null_value();
253 }
254
255
237 Handle<FixedArray> JSObject::EnsureWritableFastElements( 256 Handle<FixedArray> JSObject::EnsureWritableFastElements(
238 Handle<JSObject> object) { 257 Handle<JSObject> object) {
239 DCHECK(object->HasFastSmiOrObjectElements()); 258 DCHECK(object->HasFastSmiOrObjectElements());
240 Isolate* isolate = object->GetIsolate(); 259 Isolate* isolate = object->GetIsolate();
241 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate); 260 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate);
242 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems; 261 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
243 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap( 262 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap(
244 elems, isolate->factory()->fixed_array_map()); 263 elems, isolate->factory()->fixed_array_map());
245 object->set_elements(*writable_elems); 264 object->set_elements(*writable_elems);
246 isolate->counters()->cow_arrays_converted()->Increment(); 265 isolate->counters()->cow_arrays_converted()->Increment();
(...skipping 16572 matching lines...) Expand 10 before | Expand all | Expand 10 after
16819 Handle<DependentCode> codes = 16838 Handle<DependentCode> codes =
16820 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16839 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16821 DependentCode::kPropertyCellChangedGroup, 16840 DependentCode::kPropertyCellChangedGroup,
16822 info->object_wrapper()); 16841 info->object_wrapper());
16823 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16842 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16824 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16843 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16825 cell, info->zone()); 16844 cell, info->zone());
16826 } 16845 }
16827 16846
16828 } } // namespace v8::internal 16847 } } // namespace v8::internal
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