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

Side by Side Diff: src/stub-cache.cc

Issue 8393003: Handlify simple functions of [keyed] store stub compiler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 KeyedLoadStubCompiler compiler(isolate_); 411 KeyedLoadStubCompiler compiler(isolate_);
412 Handle<Code> code = compiler.CompileLoadFunctionPrototype(name); 412 Handle<Code> code = compiler.CompileLoadFunctionPrototype(name);
413 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name)); 413 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, *name));
414 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code)); 414 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, *name, *code));
415 JSObject::UpdateMapCodeCache(receiver, name, code); 415 JSObject::UpdateMapCodeCache(receiver, name, code);
416 return code; 416 return code;
417 } 417 }
418 418
419 419
420 Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
421 int index,
422 Handle<Map> transition,
423 Handle<String> name) {
424 CALL_HEAP_FUNCTION(
425 isolate(),
426 (set_failure(NULL),
427 CompileStoreField(*object, index,
428 transition.is_null() ? NULL : *transition,
429 *name)),
430 Code);
431 }
432
433
434 Handle<Code> StubCache::ComputeStoreField(Handle<String> name, 420 Handle<Code> StubCache::ComputeStoreField(Handle<String> name,
435 Handle<JSObject> receiver, 421 Handle<JSObject> receiver,
436 int field_index, 422 int field_index,
437 Handle<Map> transition, 423 Handle<Map> transition,
438 StrictModeFlag strict_mode) { 424 StrictModeFlag strict_mode) {
439 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION; 425 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION;
440 Code::Flags flags = Code::ComputeMonomorphicFlags( 426 Code::Flags flags = Code::ComputeMonomorphicFlags(
441 Code::STORE_IC, type, strict_mode); 427 Code::STORE_IC, type, strict_mode);
442 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); 428 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags));
443 if (probe->IsCode()) return Handle<Code>::cast(probe); 429 if (probe->IsCode()) return Handle<Code>::cast(probe);
444 430
445 StoreStubCompiler compiler(isolate_, strict_mode); 431 StoreStubCompiler compiler(isolate_, strict_mode);
446 Handle<Code> code = 432 Handle<Code> code =
447 compiler.CompileStoreField(receiver, field_index, transition, name); 433 compiler.CompileStoreField(receiver, field_index, transition, name);
448 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); 434 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name));
449 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); 435 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
450 JSObject::UpdateMapCodeCache(receiver, name, code); 436 JSObject::UpdateMapCodeCache(receiver, name, code);
451 return code; 437 return code;
452 } 438 }
453 439
454 440
455 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(Handle<Map> map) {
456 CALL_HEAP_FUNCTION(isolate(),
457 (set_failure(NULL),
458 CompileStoreElement(*map)),
459 Code);
460 }
461
462
463 Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement( 441 Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement(
464 Handle<JSObject> receiver, 442 Handle<JSObject> receiver,
465 KeyedIC::StubKind stub_kind, 443 KeyedIC::StubKind stub_kind,
466 StrictModeFlag strict_mode) { 444 StrictModeFlag strict_mode) {
467 Code::Flags flags = 445 Code::Flags flags =
468 Code::ComputeMonomorphicFlags( 446 Code::ComputeMonomorphicFlags(
469 stub_kind == KeyedIC::LOAD ? Code::KEYED_LOAD_IC 447 stub_kind == KeyedIC::LOAD ? Code::KEYED_LOAD_IC
470 : Code::KEYED_STORE_IC, 448 : Code::KEYED_STORE_IC,
471 NORMAL, 449 NORMAL,
472 strict_mode); 450 strict_mode);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if (stub_kind == KeyedIC::LOAD) { 486 if (stub_kind == KeyedIC::LOAD) {
509 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, 0)); 487 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, 0));
510 } else { 488 } else {
511 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, 0)); 489 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, 0));
512 } 490 }
513 JSObject::UpdateMapCodeCache(receiver, name, code); 491 JSObject::UpdateMapCodeCache(receiver, name, code);
514 return code; 492 return code;
515 } 493 }
516 494
517 495
518 Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
519 MapHandleList* receiver_maps,
520 CodeHandleList* handler_stubs,
521 MapHandleList* transitioned_maps) {
522 MapList raw_receiver_maps(receiver_maps->length());
523 CodeList raw_handler_stubs(handler_stubs->length());
524 MapList raw_transitioned_maps(transitioned_maps->length());
525 CALL_HEAP_FUNCTION(
526 isolate(),
527 (set_failure(NULL),
528 raw_receiver_maps.Clear(),
529 raw_handler_stubs.Clear(),
530 raw_transitioned_maps.Clear(),
531 CompileStorePolymorphic(UnwrapHandleList(&raw_receiver_maps,
532 receiver_maps),
533 UnwrapHandleList(&raw_handler_stubs,
534 handler_stubs),
535 UnwrapHandleList(&raw_transitioned_maps,
536 transitioned_maps))),
537 Code);
538 }
539
540
541 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { 496 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) {
542 return (strict_mode == kStrictMode) 497 return (strict_mode == kStrictMode)
543 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() 498 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict()
544 : isolate_->builtins()->Builtins::StoreIC_Normal(); 499 : isolate_->builtins()->Builtins::StoreIC_Normal();
545 } 500 }
546 501
547 502
548 Handle<Code> StoreStubCompiler::CompileStoreGlobal(
549 Handle<GlobalObject> object,
550 Handle<JSGlobalPropertyCell> holder,
551 Handle<String> name) {
552 CALL_HEAP_FUNCTION(isolate(),
553 (set_failure(NULL),
554 CompileStoreGlobal(*object, *holder, *name)),
555 Code);
556 }
557
558
559 Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name, 503 Handle<Code> StubCache::ComputeStoreGlobal(Handle<String> name,
560 Handle<GlobalObject> receiver, 504 Handle<GlobalObject> receiver,
561 Handle<JSGlobalPropertyCell> cell, 505 Handle<JSGlobalPropertyCell> cell,
562 StrictModeFlag strict_mode) { 506 StrictModeFlag strict_mode) {
563 Code::Flags flags = Code::ComputeMonomorphicFlags( 507 Code::Flags flags = Code::ComputeMonomorphicFlags(
564 Code::STORE_IC, NORMAL, strict_mode); 508 Code::STORE_IC, NORMAL, strict_mode);
565 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); 509 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags));
566 if (probe->IsCode()) return Handle<Code>::cast(probe); 510 if (probe->IsCode()) return Handle<Code>::cast(probe);
567 511
568 StoreStubCompiler compiler(isolate_, strict_mode); 512 StoreStubCompiler compiler(isolate_, strict_mode);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 if (probe->IsCode()) return Handle<Code>::cast(probe); 566 if (probe->IsCode()) return Handle<Code>::cast(probe);
623 567
624 StoreStubCompiler compiler(isolate_, strict_mode); 568 StoreStubCompiler compiler(isolate_, strict_mode);
625 Handle<Code> code = compiler.CompileStoreInterceptor(receiver, name); 569 Handle<Code> code = compiler.CompileStoreInterceptor(receiver, name);
626 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); 570 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name));
627 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); 571 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
628 JSObject::UpdateMapCodeCache(receiver, name, code); 572 JSObject::UpdateMapCodeCache(receiver, name, code);
629 return code; 573 return code;
630 } 574 }
631 575
632 Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
633 int index,
634 Handle<Map> transition,
635 Handle<String> name) {
636 CALL_HEAP_FUNCTION(
637 isolate(),
638 (set_failure(NULL),
639 CompileStoreField(*object, index,
640 transition.is_null() ? NULL : *transition,
641 *name)),
642 Code);
643 }
644
645 Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name, 576 Handle<Code> StubCache::ComputeKeyedStoreField(Handle<String> name,
646 Handle<JSObject> receiver, 577 Handle<JSObject> receiver,
647 int field_index, 578 int field_index,
648 Handle<Map> transition, 579 Handle<Map> transition,
649 StrictModeFlag strict_mode) { 580 StrictModeFlag strict_mode) {
650 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION; 581 PropertyType type = (transition.is_null()) ? FIELD : MAP_TRANSITION;
651 Code::Flags flags = Code::ComputeMonomorphicFlags( 582 Code::Flags flags = Code::ComputeMonomorphicFlags(
652 Code::KEYED_STORE_IC, type, strict_mode); 583 Code::KEYED_STORE_IC, type, strict_mode);
653 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags)); 584 Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags));
654 if (probe->IsCode()) return Handle<Code>::cast(probe); 585 if (probe->IsCode()) return Handle<Code>::cast(probe);
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 Code::cast(result->ToObjectUnchecked()), 1540 Code::cast(result->ToObjectUnchecked()),
1610 name)); 1541 name));
1611 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, 1542 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1612 name, 1543 name,
1613 Code::cast(result->ToObjectUnchecked()))); 1544 Code::cast(result->ToObjectUnchecked())));
1614 } 1545 }
1615 return result; 1546 return result;
1616 } 1547 }
1617 1548
1618 1549
1619 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { 1550 Handle<Code> StoreStubCompiler::GetCode(PropertyType type,
1551 Handle<String> name) {
1552 Code::Flags flags =
1553 Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
1554 Handle<Code> code = GetCodeWithFlags(flags, name);
1555 PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name));
1556 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
1557 return code;
1558 }
1559
1560
1561 // TODO(ulan): Eliminate this function when the stub cache is fully
1562 // handlified.
1563 MaybeObject* StoreStubCompiler::TryGetCode(PropertyType type, String* name) {
1620 Code::Flags flags = 1564 Code::Flags flags =
1621 Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_); 1565 Code::ComputeMonomorphicFlags(Code::STORE_IC, type, strict_mode_);
1622 MaybeObject* result = TryGetCodeWithFlags(flags, name); 1566 MaybeObject* result = TryGetCodeWithFlags(flags, name);
1623 if (!result->IsFailure()) { 1567 if (!result->IsFailure()) {
1624 PROFILE(isolate(), 1568 PROFILE(isolate(),
1625 CodeCreateEvent(Logger::STORE_IC_TAG, 1569 CodeCreateEvent(Logger::STORE_IC_TAG,
1626 Code::cast(result->ToObjectUnchecked()), 1570 Code::cast(result->ToObjectUnchecked()),
1627 name)); 1571 name));
1628 GDBJIT(AddCode(GDBJITInterface::STORE_IC, 1572 GDBJIT(AddCode(GDBJITInterface::STORE_IC,
1629 name, 1573 name,
1630 Code::cast(result->ToObjectUnchecked()))); 1574 Code::cast(result->ToObjectUnchecked())));
1631 } 1575 }
1632 return result; 1576 return result;
1633 } 1577 }
1634 1578
1635 1579
1636 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, 1580 Handle<Code> KeyedStoreStubCompiler::GetCode(PropertyType type,
1637 String* name, 1581 Handle<String> name,
1638 InlineCacheState state) { 1582 InlineCacheState state) {
1639 Code::Flags flags = 1583 Code::Flags flags =
1640 Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type); 1584 Code::ComputeFlags(Code::KEYED_STORE_IC, state, strict_mode_, type);
1641 MaybeObject* result = TryGetCodeWithFlags(flags, name); 1585 Handle<Code> code = GetCodeWithFlags(flags, name);
1642 if (!result->IsFailure()) { 1586 PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name));
1643 PROFILE(isolate(), 1587 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
1644 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, 1588 return code;
1645 Code::cast(result->ToObjectUnchecked()),
1646 name));
1647 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
1648 name,
1649 Code::cast(result->ToObjectUnchecked())));
1650 }
1651 return result;
1652 } 1589 }
1653 1590
1654 1591
1655 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement( 1592 void KeyedStoreStubCompiler::GenerateStoreDictionaryElement(
1656 MacroAssembler* masm) { 1593 MacroAssembler* masm) {
1657 KeyedStoreIC::GenerateSlow(masm); 1594 KeyedStoreIC::GenerateSlow(masm);
1658 } 1595 }
1659 1596
1660 1597
1661 CallStubCompiler::CallStubCompiler(Isolate* isolate, 1598 CallStubCompiler::CallStubCompiler(Isolate* isolate,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 expected_receiver_type_ = 1775 expected_receiver_type_ =
1839 FunctionTemplateInfo::cast(signature->receiver()); 1776 FunctionTemplateInfo::cast(signature->receiver());
1840 } 1777 }
1841 } 1778 }
1842 1779
1843 is_simple_api_call_ = true; 1780 is_simple_api_call_ = true;
1844 } 1781 }
1845 1782
1846 1783
1847 } } // namespace v8::internal 1784 } } // namespace v8::internal
OLDNEW
« src/list-inl.h ('K') | « src/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698