 Chromium Code Reviews
 Chromium Code Reviews Issue 188783003:
  Make maps in monomorphic IC stubs weak.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 188783003:
  Make maps in monomorphic IC stubs weak.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 info->change_own_type_change_checksum(); | 428 info->change_own_type_change_checksum(); | 
| 429 } | 429 } | 
| 430 host->set_profiler_ticks(0); | 430 host->set_profiler_ticks(0); | 
| 431 isolate->runtime_profiler()->NotifyICChanged(); | 431 isolate->runtime_profiler()->NotifyICChanged(); | 
| 432 // TODO(2029): When an optimized function is patched, it would | 432 // TODO(2029): When an optimized function is patched, it would | 
| 433 // be nice to propagate the corresponding type information to its | 433 // be nice to propagate the corresponding type information to its | 
| 434 // unoptimized version for the benefit of later inlining. | 434 // unoptimized version for the benefit of later inlining. | 
| 435 } | 435 } | 
| 436 | 436 | 
| 437 | 437 | 
| 438 void IC::RegisterWeakMapDependency(Handle<Code> stub) { | |
| 439 if (FLAG_collect_maps && FLAG_weak_embedded_maps_in_ic) { | |
| 440 if (stub->is_weak_stub()) { | |
| 441 MapHandleList maps; | |
| 442 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); | |
| 443 for (RelocIterator it(*stub, mode_mask); !it.done(); it.next()) { | |
| 444 if (it.rinfo()->target_object()->IsMap()) { | |
| 445 Handle<Map> map(Map::cast(it.rinfo()->target_object())); | |
| 446 if (stub->IsWeakObject(*map)) { | |
| 447 maps.Add(map); | |
| 448 } | |
| 449 } | |
| 450 } | |
| 451 #ifdef VERIFY_HEAP | |
| 452 // This disables verification of weak embedded maps after full GC. | |
| 453 // AddDependentCode can cause a GC, which would observe the state where | |
| 454 // this code is not yet in the depended code lists of the embedded maps. | |
| 455 NoWeakObjectVerificationScope disable_verification_of_objects; | |
| 456 #endif | |
| 457 for (int i = 0; i < maps.length(); i++) { | |
| 458 maps.at(i)->AddDependentCode(DependentCode::kWeaklyEmbeddedGroup, stub); | |
| 
Toon Verwaest
2014/04/03 15:18:36
This means that all maps have 2 pointers to monomo
 
ulan
2014/04/03 15:40:26
As discussed offline, we can probably do that if l
 | |
| 459 } | |
| 460 } | |
| 461 } | |
| 462 } | |
| 463 | |
| 464 | |
| 465 Code* IC::MissBuiltin(Isolate* isolate, Code* stub) { | |
| 466 switch (stub->kind()) { | |
| 467 case Code::LOAD_IC: | |
| 468 case Code::STORE_IC: | |
| 469 case Code::KEYED_LOAD_IC: | |
| 470 case Code::KEYED_STORE_IC: { | |
| 471 return isolate->builtins()->builtin( | |
| 472 BaseLoadStoreStubCompiler::MissBuiltin(stub->kind())); | |
| 
Toon Verwaest
2014/04/03 15:18:36
4-space indent
 
ulan
2014/04/03 15:40:26
Done.
 | |
| 473 } | |
| 474 case Code::COMPARE_NIL_IC: { | |
| 475 ExtraICState state = stub->extra_ic_state(); | |
| 476 CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED); | |
| 477 stub.ClearState(); | |
| 478 Code* code = NULL; | |
| 479 CHECK(stub.FindCodeInCache(&code, isolate)); | |
| 480 return code; | |
| 481 } | |
| 482 default: | |
| 483 UNREACHABLE(); | |
| 484 } | |
| 485 return NULL; | |
| 486 } | |
| 487 | |
| 488 | |
| 489 void IC::InvalidateMapsAndHandlers(Code* stub) { | |
| 490 ASSERT(stub->is_weak_stub()); | |
| 491 Isolate* isolate = stub->GetIsolate(); | |
| 492 Heap* heap = isolate->heap(); | |
| 493 Code* miss = MissBuiltin(isolate, stub); | |
| 494 Object* undefined = heap->undefined_value(); | |
| 495 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | |
| 496 RelocInfo::ModeMask(RelocInfo::CODE_TARGET); | |
| 497 // Set every map to undefined and every code target to the miss builtin. | |
| 498 for (RelocIterator it(stub, mode_mask); !it.done(); it.next()) { | |
| 499 RelocInfo::Mode mode = it.rinfo()->rmode(); | |
| 500 if (mode == RelocInfo::EMBEDDED_OBJECT && | |
| 501 it.rinfo()->target_object()->IsMap()) { | |
| 502 it.rinfo()->set_target_object(undefined, SKIP_WRITE_BARRIER); | |
| 503 } else if (mode == RelocInfo::CODE_TARGET) { | |
| 504 Address address = it.rinfo()->pc(); | |
| 505 Assembler::set_target_address_at( | |
| 506 address, stub, miss->instruction_start()); | |
| 507 if (heap->gc_state() == Heap::MARK_COMPACT) { | |
| 508 heap->mark_compact_collector()->RecordCodeTargetPatch(address, miss); | |
| 509 } else { | |
| 510 heap->incremental_marking()->RecordCodeTargetPatch(address, miss); | |
| 511 } | |
| 512 } | |
| 513 } | |
| 514 CPU::FlushICache(stub->instruction_start(), stub->instruction_size()); | |
| 515 } | |
| 516 | |
| 517 | |
| 438 void IC::Clear(Isolate* isolate, Address address, | 518 void IC::Clear(Isolate* isolate, Address address, | 
| 439 ConstantPoolArray* constant_pool) { | 519 ConstantPoolArray* constant_pool) { | 
| 440 Code* target = GetTargetAtAddress(address, constant_pool); | 520 Code* target = GetTargetAtAddress(address, constant_pool); | 
| 441 | 521 | 
| 442 // Don't clear debug break inline cache as it will remove the break point. | 522 // Don't clear debug break inline cache as it will remove the break point. | 
| 443 if (target->is_debug_stub()) return; | 523 if (target->is_debug_stub()) return; | 
| 444 | 524 | 
| 445 switch (target->kind()) { | 525 switch (target->kind()) { | 
| 446 case Code::LOAD_IC: | 526 case Code::LOAD_IC: | 
| 447 return LoadIC::Clear(isolate, address, target, constant_pool); | 527 return LoadIC::Clear(isolate, address, target, constant_pool); | 
| (...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2833 #undef ADDR | 2913 #undef ADDR | 
| 2834 }; | 2914 }; | 
| 2835 | 2915 | 
| 2836 | 2916 | 
| 2837 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2917 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 
| 2838 return IC_utilities[id]; | 2918 return IC_utilities[id]; | 
| 2839 } | 2919 } | 
| 2840 | 2920 | 
| 2841 | 2921 | 
| 2842 } } // namespace v8::internal | 2922 } } // namespace v8::internal | 
| OLD | NEW |