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

Side by Side Diff: src/ic/handler-compiler.cc

Issue 1185373004: Only walk the hidden prototype chain for private nonexistent symbols (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « no previous file | test/mjsunit/regress/regress-479528.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/cpu-profiler.h" 7 #include "src/cpu-profiler.h"
8 #include "src/ic/call-optimization.h" 8 #include "src/ic/call-optimization.h"
9 #include "src/ic/handler-compiler.h" 9 #include "src/ic/handler-compiler.h"
10 #include "src/ic/ic.h" 10 #include "src/ic/ic.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // therefore the stub will be specific to the name. 46 // therefore the stub will be specific to the name.
47 Handle<Name> cache_name = 47 Handle<Name> cache_name =
48 receiver_map->is_dictionary_map() 48 receiver_map->is_dictionary_map()
49 ? name 49 ? name
50 : Handle<Name>::cast(isolate->factory()->nonexistent_symbol()); 50 : Handle<Name>::cast(isolate->factory()->nonexistent_symbol());
51 Handle<Map> current_map = stub_holder_map; 51 Handle<Map> current_map = stub_holder_map;
52 Handle<JSObject> last(JSObject::cast(receiver_map->prototype())); 52 Handle<JSObject> last(JSObject::cast(receiver_map->prototype()));
53 while (true) { 53 while (true) {
54 if (current_map->is_dictionary_map()) cache_name = name; 54 if (current_map->is_dictionary_map()) cache_name = name;
55 if (current_map->prototype()->IsNull()) break; 55 if (current_map->prototype()->IsNull()) break;
56 if (name->IsPrivate()) {
57 // TODO(verwaest): Use nonexistent_private_symbol.
58 cache_name = name;
59 JSReceiver* prototype = JSReceiver::cast(current_map->prototype());
60 if (!prototype->map()->is_hidden_prototype() &&
61 !prototype->map()->IsGlobalObjectMap()) {
62 break;
63 }
64 }
65
56 last = handle(JSObject::cast(current_map->prototype())); 66 last = handle(JSObject::cast(current_map->prototype()));
57 current_map = handle(last->map()); 67 current_map = handle(last->map());
58 } 68 }
59 // Compile the stub that is either shared for all names or 69 // Compile the stub that is either shared for all names or
60 // name specific if there are global objects involved. 70 // name specific if there are global objects involved.
61 Handle<Code> handler = PropertyHandlerCompiler::Find( 71 Handle<Code> handler = PropertyHandlerCompiler::Find(
62 cache_name, stub_holder_map, Code::LOAD_IC, flag, Code::FAST); 72 cache_name, stub_holder_map, Code::LOAD_IC, flag, Code::FAST);
63 if (!handler.is_null()) return handler; 73 if (!handler.is_null()) return handler;
64 74
65 NamedLoadHandlerCompiler compiler(isolate, receiver_map, last, flag); 75 NamedLoadHandlerCompiler compiler(isolate, receiver_map, last, flag);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // TODO(verwaest): Cleanup. holder() is actually the receiver. 431 // TODO(verwaest): Cleanup. holder() is actually the receiver.
422 Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition( 432 Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
423 Handle<Map> transition, Handle<Name> name) { 433 Handle<Map> transition, Handle<Name> name) {
424 Label miss; 434 Label miss;
425 435
426 // Check that we are allowed to write this. 436 // Check that we are allowed to write this.
427 bool is_nonexistent = holder()->map() == transition->GetBackPointer(); 437 bool is_nonexistent = holder()->map() == transition->GetBackPointer();
428 if (is_nonexistent) { 438 if (is_nonexistent) {
429 // Find the top object. 439 // Find the top object.
430 Handle<JSObject> last; 440 Handle<JSObject> last;
441 PrototypeIterator::WhereToEnd end =
442 name->IsPrivate() ? PrototypeIterator::END_AT_NON_HIDDEN
443 : PrototypeIterator::END_AT_NULL;
431 PrototypeIterator iter(isolate(), holder()); 444 PrototypeIterator iter(isolate(), holder());
432 while (!iter.IsAtEnd()) { 445 while (!iter.IsAtEnd(end)) {
433 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); 446 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter));
434 iter.Advance(); 447 iter.Advance();
435 } 448 }
436 if (!last.is_null()) set_holder(last); 449 if (!last.is_null()) set_holder(last);
437 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2()); 450 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2());
438 } else { 451 } else {
439 FrontendHeader(receiver(), name, &miss, DONT_RETURN_ANYTHING); 452 FrontendHeader(receiver(), name, &miss, DONT_RETURN_ANYTHING);
440 DCHECK(holder()->HasFastProperties()); 453 DCHECK(holder()->HasFastProperties());
441 } 454 }
442 455
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 DCHECK(elements_kind == DICTIONARY_ELEMENTS); 569 DCHECK(elements_kind == DICTIONARY_ELEMENTS);
557 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); 570 cached_stub = LoadDictionaryElementStub(isolate()).GetCode();
558 } 571 }
559 } 572 }
560 573
561 handlers->Add(cached_stub); 574 handlers->Add(cached_stub);
562 } 575 }
563 } 576 }
564 } // namespace internal 577 } // namespace internal
565 } // namespace v8 578 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-479528.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698