OLD | NEW |
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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 StoreStubCompiler compiler(isolate_, strict_mode); | 535 StoreStubCompiler compiler(isolate_, strict_mode); |
536 Handle<Code> code = | 536 Handle<Code> code = |
537 compiler.CompileStoreField(receiver, field_index, transition, name); | 537 compiler.CompileStoreField(receiver, field_index, transition, name); |
538 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); | 538 PROFILE(isolate_, CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name)); |
539 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); | 539 GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code)); |
540 JSObject::UpdateMapCodeCache(receiver, name, code); | 540 JSObject::UpdateMapCodeCache(receiver, name, code); |
541 return code; | 541 return code; |
542 } | 542 } |
543 | 543 |
544 | 544 |
545 MaybeObject* StubCache::ComputeKeyedLoadOrStoreElement( | 545 Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(Handle<Map> map) { |
546 JSObject* receiver, | 546 CALL_HEAP_FUNCTION(isolate(), |
| 547 (set_failure(NULL), CompileLoadElement(*map)), |
| 548 Code); |
| 549 } |
| 550 |
| 551 |
| 552 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(Handle<Map> map) { |
| 553 CALL_HEAP_FUNCTION(isolate(), |
| 554 (set_failure(NULL), |
| 555 CompileStoreElement(*map)), |
| 556 Code); |
| 557 } |
| 558 |
| 559 |
| 560 Handle<Code> StubCache::ComputeKeyedLoadOrStoreElement( |
| 561 Handle<JSObject> receiver, |
547 KeyedIC::StubKind stub_kind, | 562 KeyedIC::StubKind stub_kind, |
548 StrictModeFlag strict_mode) { | 563 StrictModeFlag strict_mode) { |
549 Code::Flags flags = | 564 Code::Flags flags = |
550 Code::ComputeMonomorphicFlags( | 565 Code::ComputeMonomorphicFlags( |
551 stub_kind == KeyedIC::LOAD ? Code::KEYED_LOAD_IC | 566 stub_kind == KeyedIC::LOAD ? Code::KEYED_LOAD_IC |
552 : Code::KEYED_STORE_IC, | 567 : Code::KEYED_STORE_IC, |
553 NORMAL, | 568 NORMAL, |
554 strict_mode); | 569 strict_mode); |
555 String* name = NULL; | 570 Handle<String> name; |
556 switch (stub_kind) { | 571 switch (stub_kind) { |
557 case KeyedIC::LOAD: | 572 case KeyedIC::LOAD: |
558 name = isolate()->heap()->KeyedLoadElementMonomorphic_symbol(); | 573 name = isolate()->factory()->KeyedLoadElementMonomorphic_symbol(); |
559 break; | 574 break; |
560 case KeyedIC::STORE_NO_TRANSITION: | 575 case KeyedIC::STORE_NO_TRANSITION: |
561 name = isolate()->heap()->KeyedStoreElementMonomorphic_symbol(); | 576 name = isolate()->factory()->KeyedStoreElementMonomorphic_symbol(); |
562 break; | 577 break; |
563 default: | 578 default: |
564 UNREACHABLE(); | 579 UNREACHABLE(); |
565 break; | 580 break; |
566 } | 581 } |
567 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags); | 582 Handle<Map> receiver_map(receiver->map()); |
568 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code); | 583 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags)); |
| 584 if (probe->IsCode()) return Handle<Code>::cast(probe); |
569 | 585 |
570 Map* receiver_map = receiver->map(); | 586 Handle<Code> code; |
571 MaybeObject* maybe_new_code = NULL; | |
572 switch (stub_kind) { | 587 switch (stub_kind) { |
573 case KeyedIC::LOAD: { | 588 case KeyedIC::LOAD: { |
574 HandleScope scope(isolate_); | |
575 KeyedLoadStubCompiler compiler(isolate_); | 589 KeyedLoadStubCompiler compiler(isolate_); |
576 maybe_new_code = compiler.CompileLoadElement(receiver_map); | 590 code = compiler.CompileLoadElement(receiver_map); |
577 break; | 591 break; |
578 } | 592 } |
579 case KeyedIC::STORE_NO_TRANSITION: { | 593 case KeyedIC::STORE_NO_TRANSITION: { |
580 HandleScope scope(isolate_); | |
581 KeyedStoreStubCompiler compiler(isolate_, strict_mode); | 594 KeyedStoreStubCompiler compiler(isolate_, strict_mode); |
582 maybe_new_code = compiler.CompileStoreElement(receiver_map); | 595 code = compiler.CompileStoreElement(receiver_map); |
583 break; | 596 break; |
584 } | 597 } |
585 default: | 598 default: |
586 UNREACHABLE(); | 599 UNREACHABLE(); |
587 break; | 600 break; |
588 } | 601 } |
589 Code* code = NULL; | 602 |
590 if (!maybe_new_code->To(&code)) return maybe_new_code; | 603 ASSERT(!code.is_null()); |
591 | 604 |
592 if (stub_kind == KeyedIC::LOAD) { | 605 if (stub_kind == KeyedIC::LOAD) { |
593 PROFILE(isolate_, | 606 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, *code, 0)); |
594 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, | |
595 Code::cast(code), 0)); | |
596 } else { | 607 } else { |
597 PROFILE(isolate_, | 608 PROFILE(isolate_, CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, 0)); |
598 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, | |
599 Code::cast(code), 0)); | |
600 } | 609 } |
601 ASSERT(code->IsCode()); | 610 JSObject::UpdateMapCodeCache(receiver, name, code); |
602 Object* result; | |
603 { MaybeObject* maybe_result = | |
604 receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
605 if (!maybe_result->ToObject(&result)) return maybe_result; | |
606 } | |
607 return code; | 611 return code; |
608 } | 612 } |
609 | 613 |
610 | 614 |
| 615 Handle<Code> KeyedLoadStubCompiler::CompileLoadPolymorphic( |
| 616 MapHandleList* receiver_maps, |
| 617 CodeHandleList* handler_stubs) { |
| 618 MapList raw_receiver_maps(receiver_maps->length()); |
| 619 CodeList raw_handler_stubs(handler_stubs->length()); |
| 620 CALL_HEAP_FUNCTION( |
| 621 isolate(), |
| 622 (set_failure(NULL), |
| 623 raw_receiver_maps.Clear(), |
| 624 raw_handler_stubs.Clear(), |
| 625 CompileLoadPolymorphic(UnwrapHandleList(&raw_receiver_maps, |
| 626 receiver_maps), |
| 627 UnwrapHandleList(&raw_handler_stubs, |
| 628 handler_stubs))), |
| 629 Code); |
| 630 } |
| 631 |
| 632 |
| 633 Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic( |
| 634 MapHandleList* receiver_maps, |
| 635 CodeHandleList* handler_stubs, |
| 636 MapHandleList* transitioned_maps) { |
| 637 MapList raw_receiver_maps(receiver_maps->length()); |
| 638 CodeList raw_handler_stubs(handler_stubs->length()); |
| 639 MapList raw_transitioned_maps(transitioned_maps->length()); |
| 640 CALL_HEAP_FUNCTION( |
| 641 isolate(), |
| 642 (set_failure(NULL), |
| 643 raw_receiver_maps.Clear(), |
| 644 raw_handler_stubs.Clear(), |
| 645 raw_transitioned_maps.Clear(), |
| 646 CompileStorePolymorphic(UnwrapHandleList(&raw_receiver_maps, |
| 647 receiver_maps), |
| 648 UnwrapHandleList(&raw_handler_stubs, |
| 649 handler_stubs), |
| 650 UnwrapHandleList(&raw_transitioned_maps, |
| 651 transitioned_maps))), |
| 652 Code); |
| 653 } |
| 654 |
| 655 |
611 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { | 656 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { |
612 return (strict_mode == kStrictMode) | 657 return (strict_mode == kStrictMode) |
613 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() | 658 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() |
614 : isolate_->builtins()->Builtins::StoreIC_Normal(); | 659 : isolate_->builtins()->Builtins::StoreIC_Normal(); |
615 } | 660 } |
616 | 661 |
617 | 662 |
618 Handle<Code> StoreStubCompiler::CompileStoreGlobal( | 663 Handle<Code> StoreStubCompiler::CompileStoreGlobal( |
619 Handle<GlobalObject> object, | 664 Handle<GlobalObject> object, |
620 Handle<JSGlobalPropertyCell> holder, | 665 Handle<JSGlobalPropertyCell> holder, |
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 expected_receiver_type_ = | 1979 expected_receiver_type_ = |
1935 FunctionTemplateInfo::cast(signature->receiver()); | 1980 FunctionTemplateInfo::cast(signature->receiver()); |
1936 } | 1981 } |
1937 } | 1982 } |
1938 | 1983 |
1939 is_simple_api_call_ = true; | 1984 is_simple_api_call_ = true; |
1940 } | 1985 } |
1941 | 1986 |
1942 | 1987 |
1943 } } // namespace v8::internal | 1988 } } // namespace v8::internal |
OLD | NEW |