| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 Object* result; | 460 Object* result; |
| 461 { MaybeObject* maybe_result = | 461 { MaybeObject* maybe_result = |
| 462 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 462 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 463 if (!maybe_result->ToObject(&result)) return maybe_result; | 463 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 return code; | 466 return code; |
| 467 } | 467 } |
| 468 | 468 |
| 469 | 469 |
| 470 MaybeObject* StubCache::ComputeKeyedLoadPixelArray(JSObject* receiver) { | |
| 471 // Using NORMAL as the PropertyType for array element loads is a misuse. The | |
| 472 // generated stub always accesses fast elements, not slow-mode fields, but | |
| 473 // some property type is required for the stub lookup. Note that overloading | |
| 474 // the NORMAL PropertyType is only safe as long as no stubs are generated for | |
| 475 // other keyed field loads. This is guaranteed to be the case since all field | |
| 476 // keyed loads that are not array elements go through a generic builtin stub. | |
| 477 Code::Flags flags = | |
| 478 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); | |
| 479 String* name = Heap::KeyedLoadPixelArray_symbol(); | |
| 480 Object* code = receiver->map()->FindInCodeCache(name, flags); | |
| 481 if (code->IsUndefined()) { | |
| 482 KeyedLoadStubCompiler compiler; | |
| 483 { MaybeObject* maybe_code = compiler.CompileLoadPixelArray(receiver); | |
| 484 if (!maybe_code->ToObject(&code)) return maybe_code; | |
| 485 } | |
| 486 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | |
| 487 Object* result; | |
| 488 { MaybeObject* maybe_result = | |
| 489 receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 490 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 491 } | |
| 492 } | |
| 493 return code; | |
| 494 } | |
| 495 | |
| 496 | |
| 497 MaybeObject* StubCache::ComputeStoreField(String* name, | 470 MaybeObject* StubCache::ComputeStoreField(String* name, |
| 498 JSObject* receiver, | 471 JSObject* receiver, |
| 499 int field_index, | 472 int field_index, |
| 500 Map* transition, | 473 Map* transition, |
| 501 Code::ExtraICState extra_ic_state) { | 474 StrictModeFlag strict_mode) { |
| 502 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 475 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 503 Code::Flags flags = Code::ComputeMonomorphicFlags( | 476 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 504 Code::STORE_IC, type, extra_ic_state); | 477 Code::STORE_IC, type, strict_mode); |
| 505 Object* code = receiver->map()->FindInCodeCache(name, flags); | 478 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 506 if (code->IsUndefined()) { | 479 if (code->IsUndefined()) { |
| 507 StoreStubCompiler compiler(extra_ic_state); | 480 StoreStubCompiler compiler(strict_mode); |
| 508 { MaybeObject* maybe_code = | 481 { MaybeObject* maybe_code = |
| 509 compiler.CompileStoreField(receiver, field_index, transition, name); | 482 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 510 if (!maybe_code->ToObject(&code)) return maybe_code; | 483 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 511 } | 484 } |
| 512 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 485 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 513 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); | 486 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 514 Object* result; | 487 Object* result; |
| 515 { MaybeObject* maybe_result = | 488 { MaybeObject* maybe_result = |
| 516 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 489 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 517 if (!maybe_result->ToObject(&result)) return maybe_result; | 490 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 518 } | 491 } |
| 519 } | 492 } |
| 520 return code; | 493 return code; |
| 521 } | 494 } |
| 522 | 495 |
| 523 | 496 |
| 524 MaybeObject* StubCache::ComputeKeyedStoreSpecialized(JSObject* receiver) { | 497 MaybeObject* StubCache::ComputeKeyedStoreSpecialized( |
| 498 JSObject* receiver, |
| 499 StrictModeFlag strict_mode) { |
| 525 Code::Flags flags = | 500 Code::Flags flags = |
| 526 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL); | 501 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL, strict_mode); |
| 527 String* name = Heap::KeyedStoreSpecialized_symbol(); | 502 String* name = Heap::KeyedStoreSpecialized_symbol(); |
| 528 Object* code = receiver->map()->FindInCodeCache(name, flags); | 503 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 529 if (code->IsUndefined()) { | 504 if (code->IsUndefined()) { |
| 530 KeyedStoreStubCompiler compiler; | 505 KeyedStoreStubCompiler compiler(strict_mode); |
| 531 { MaybeObject* maybe_code = compiler.CompileStoreSpecialized(receiver); | 506 { MaybeObject* maybe_code = compiler.CompileStoreSpecialized(receiver); |
| 532 if (!maybe_code->ToObject(&code)) return maybe_code; | 507 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 533 } | 508 } |
| 534 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); | 509 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); |
| 535 Object* result; | 510 Object* result; |
| 536 { MaybeObject* maybe_result = | 511 { MaybeObject* maybe_result = |
| 537 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 512 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 538 if (!maybe_result->ToObject(&result)) return maybe_result; | 513 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 539 } | 514 } |
| 540 } | 515 } |
| 541 return code; | 516 return code; |
| 542 } | 517 } |
| 543 | 518 |
| 544 | 519 |
| 545 MaybeObject* StubCache::ComputeKeyedStorePixelArray(JSObject* receiver) { | |
| 546 // Using NORMAL as the PropertyType for array element stores is a misuse. The | |
| 547 // generated stub always accesses fast elements, not slow-mode fields, but | |
| 548 // some property type is required for the stub lookup. Note that overloading | |
| 549 // the NORMAL PropertyType is only safe as long as no stubs are generated for | |
| 550 // other keyed field stores. This is guaranteed to be the case since all field | |
| 551 // keyed stores that are not array elements go through a generic builtin stub. | |
| 552 Code::Flags flags = | |
| 553 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, NORMAL); | |
| 554 String* name = Heap::KeyedStorePixelArray_symbol(); | |
| 555 Object* code = receiver->map()->FindInCodeCache(name, flags); | |
| 556 if (code->IsUndefined()) { | |
| 557 KeyedStoreStubCompiler compiler; | |
| 558 { MaybeObject* maybe_code = compiler.CompileStorePixelArray(receiver); | |
| 559 if (!maybe_code->ToObject(&code)) return maybe_code; | |
| 560 } | |
| 561 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); | |
| 562 Object* result; | |
| 563 { MaybeObject* maybe_result = | |
| 564 receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
| 565 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 566 } | |
| 567 } | |
| 568 return code; | |
| 569 } | |
| 570 | |
| 571 | |
| 572 namespace { | 520 namespace { |
| 573 | 521 |
| 574 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { | 522 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { |
| 575 switch (kind) { | 523 switch (kind) { |
| 576 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 524 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
| 577 return kExternalByteArray; | 525 return kExternalByteArray; |
| 578 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 526 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 579 return kExternalUnsignedByteArray; | 527 return kExternalUnsignedByteArray; |
| 580 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 528 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
| 581 return kExternalShortArray; | 529 return kExternalShortArray; |
| 582 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 530 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 583 return kExternalUnsignedShortArray; | 531 return kExternalUnsignedShortArray; |
| 584 case JSObject::EXTERNAL_INT_ELEMENTS: | 532 case JSObject::EXTERNAL_INT_ELEMENTS: |
| 585 return kExternalIntArray; | 533 return kExternalIntArray; |
| 586 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 534 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 587 return kExternalUnsignedIntArray; | 535 return kExternalUnsignedIntArray; |
| 588 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 536 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
| 589 return kExternalFloatArray; | 537 return kExternalFloatArray; |
| 538 case JSObject::EXTERNAL_PIXEL_ELEMENTS: |
| 539 return kExternalPixelArray; |
| 590 default: | 540 default: |
| 591 UNREACHABLE(); | 541 UNREACHABLE(); |
| 592 return static_cast<ExternalArrayType>(0); | 542 return static_cast<ExternalArrayType>(0); |
| 593 } | 543 } |
| 594 } | 544 } |
| 595 | 545 |
| 546 String* ExternalArrayTypeToStubName(ExternalArrayType array_type, |
| 547 bool is_store) { |
| 548 if (is_store) { |
| 549 switch (array_type) { |
| 550 case kExternalByteArray: |
| 551 return Heap::KeyedStoreExternalByteArray_symbol(); |
| 552 case kExternalUnsignedByteArray: |
| 553 return Heap::KeyedStoreExternalUnsignedByteArray_symbol(); |
| 554 case kExternalShortArray: |
| 555 return Heap::KeyedStoreExternalShortArray_symbol(); |
| 556 case kExternalUnsignedShortArray: |
| 557 return Heap::KeyedStoreExternalUnsignedShortArray_symbol(); |
| 558 case kExternalIntArray: |
| 559 return Heap::KeyedStoreExternalIntArray_symbol(); |
| 560 case kExternalUnsignedIntArray: |
| 561 return Heap::KeyedStoreExternalUnsignedIntArray_symbol(); |
| 562 case kExternalFloatArray: |
| 563 return Heap::KeyedStoreExternalFloatArray_symbol(); |
| 564 case kExternalPixelArray: |
| 565 return Heap::KeyedStoreExternalPixelArray_symbol(); |
| 566 default: |
| 567 UNREACHABLE(); |
| 568 return NULL; |
| 569 } |
| 570 } else { |
| 571 switch (array_type) { |
| 572 case kExternalByteArray: |
| 573 return Heap::KeyedLoadExternalByteArray_symbol(); |
| 574 case kExternalUnsignedByteArray: |
| 575 return Heap::KeyedLoadExternalUnsignedByteArray_symbol(); |
| 576 case kExternalShortArray: |
| 577 return Heap::KeyedLoadExternalShortArray_symbol(); |
| 578 case kExternalUnsignedShortArray: |
| 579 return Heap::KeyedLoadExternalUnsignedShortArray_symbol(); |
| 580 case kExternalIntArray: |
| 581 return Heap::KeyedLoadExternalIntArray_symbol(); |
| 582 case kExternalUnsignedIntArray: |
| 583 return Heap::KeyedLoadExternalUnsignedIntArray_symbol(); |
| 584 case kExternalFloatArray: |
| 585 return Heap::KeyedLoadExternalFloatArray_symbol(); |
| 586 case kExternalPixelArray: |
| 587 return Heap::KeyedLoadExternalPixelArray_symbol(); |
| 588 default: |
| 589 UNREACHABLE(); |
| 590 return NULL; |
| 591 } |
| 592 } |
| 593 } |
| 594 |
| 596 } // anonymous namespace | 595 } // anonymous namespace |
| 597 | 596 |
| 598 | 597 |
| 599 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( | 598 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( |
| 600 JSObject* receiver, | 599 JSObject* receiver, |
| 601 bool is_store) { | 600 bool is_store, |
| 601 StrictModeFlag strict_mode) { |
| 602 Code::Flags flags = | 602 Code::Flags flags = |
| 603 Code::ComputeMonomorphicFlags( | 603 Code::ComputeMonomorphicFlags( |
| 604 is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC, | 604 is_store ? Code::KEYED_EXTERNAL_ARRAY_STORE_IC : |
| 605 NORMAL); | 605 Code::KEYED_EXTERNAL_ARRAY_LOAD_IC, |
| 606 NORMAL, |
| 607 strict_mode); |
| 606 ExternalArrayType array_type = | 608 ExternalArrayType array_type = |
| 607 ElementsKindToExternalArrayType(receiver->GetElementsKind()); | 609 ElementsKindToExternalArrayType(receiver->GetElementsKind()); |
| 608 String* name = | 610 String* name = ExternalArrayTypeToStubName(array_type, is_store); |
| 609 is_store ? Heap::KeyedStoreExternalArray_symbol() | 611 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 610 : Heap::KeyedLoadExternalArray_symbol(); | |
| 611 // Use the global maps for the particular external array types, | |
| 612 // rather than the receiver's map, when looking up the cached code, | |
| 613 // so that we actually canonicalize these stubs. | |
| 614 Map* map = Heap::MapForExternalArrayType(array_type); | |
| 615 Object* code = map->FindInCodeCache(name, flags); | |
| 616 if (code->IsUndefined()) { | 612 if (code->IsUndefined()) { |
| 617 ExternalArrayStubCompiler compiler; | 613 ExternalArrayStubCompiler compiler; |
| 618 { MaybeObject* maybe_code = | 614 { MaybeObject* maybe_code = |
| 619 is_store ? compiler.CompileKeyedStoreStub(array_type, flags) : | 615 is_store ? |
| 620 compiler.CompileKeyedLoadStub(array_type, flags); | 616 compiler.CompileKeyedStoreStub(receiver, array_type, flags) : |
| 617 compiler.CompileKeyedLoadStub(receiver, array_type, flags); |
| 621 if (!maybe_code->ToObject(&code)) return maybe_code; | 618 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 622 } | 619 } |
| 620 Code::cast(code)->set_external_array_type(array_type); |
| 623 if (is_store) { | 621 if (is_store) { |
| 624 PROFILE( | 622 PROFILE( |
| 625 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); | 623 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, |
| 624 Code::cast(code), 0)); |
| 626 } else { | 625 } else { |
| 627 PROFILE( | 626 PROFILE( |
| 628 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | 627 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, |
| 628 Code::cast(code), 0)); |
| 629 } | 629 } |
| 630 Object* result; | 630 Object* result; |
| 631 { MaybeObject* maybe_result = | 631 { MaybeObject* maybe_result = |
| 632 map->UpdateCodeCache(name, Code::cast(code)); | 632 receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
| 633 if (!maybe_result->ToObject(&result)) return maybe_result; | 633 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 return code; | 636 return code; |
| 637 } | 637 } |
| 638 | 638 |
| 639 | 639 |
| 640 MaybeObject* StubCache::ComputeStoreNormal(Code::ExtraICState extra_ic_state) { | 640 MaybeObject* StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { |
| 641 return Builtins::builtin(extra_ic_state == StoreIC::kStoreICStrict | 641 return Builtins::builtin((strict_mode == kStrictMode) |
| 642 ? Builtins::StoreIC_Normal_Strict | 642 ? Builtins::StoreIC_Normal_Strict |
| 643 : Builtins::StoreIC_Normal); | 643 : Builtins::StoreIC_Normal); |
| 644 } | 644 } |
| 645 | 645 |
| 646 | 646 |
| 647 MaybeObject* StubCache::ComputeStoreGlobal(String* name, | 647 MaybeObject* StubCache::ComputeStoreGlobal(String* name, |
| 648 GlobalObject* receiver, | 648 GlobalObject* receiver, |
| 649 JSGlobalPropertyCell* cell, | 649 JSGlobalPropertyCell* cell, |
| 650 Code::ExtraICState extra_ic_state) { | 650 StrictModeFlag strict_mode) { |
| 651 Code::Flags flags = Code::ComputeMonomorphicFlags( | 651 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 652 Code::STORE_IC, NORMAL, extra_ic_state); | 652 Code::STORE_IC, NORMAL, strict_mode); |
| 653 Object* code = receiver->map()->FindInCodeCache(name, flags); | 653 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 654 if (code->IsUndefined()) { | 654 if (code->IsUndefined()) { |
| 655 StoreStubCompiler compiler(extra_ic_state); | 655 StoreStubCompiler compiler(strict_mode); |
| 656 { MaybeObject* maybe_code = | 656 { MaybeObject* maybe_code = |
| 657 compiler.CompileStoreGlobal(receiver, cell, name); | 657 compiler.CompileStoreGlobal(receiver, cell, name); |
| 658 if (!maybe_code->ToObject(&code)) return maybe_code; | 658 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 659 } | 659 } |
| 660 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 660 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 661 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); | 661 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 662 Object* result; | 662 Object* result; |
| 663 { MaybeObject* maybe_result = | 663 { MaybeObject* maybe_result = |
| 664 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 664 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 665 if (!maybe_result->ToObject(&result)) return maybe_result; | 665 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 return code; | 668 return code; |
| 669 } | 669 } |
| 670 | 670 |
| 671 | 671 |
| 672 MaybeObject* StubCache::ComputeStoreCallback( | 672 MaybeObject* StubCache::ComputeStoreCallback( |
| 673 String* name, | 673 String* name, |
| 674 JSObject* receiver, | 674 JSObject* receiver, |
| 675 AccessorInfo* callback, | 675 AccessorInfo* callback, |
| 676 Code::ExtraICState extra_ic_state) { | 676 StrictModeFlag strict_mode) { |
| 677 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); | 677 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); |
| 678 Code::Flags flags = Code::ComputeMonomorphicFlags( | 678 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 679 Code::STORE_IC, CALLBACKS, extra_ic_state); | 679 Code::STORE_IC, CALLBACKS, strict_mode); |
| 680 Object* code = receiver->map()->FindInCodeCache(name, flags); | 680 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 681 if (code->IsUndefined()) { | 681 if (code->IsUndefined()) { |
| 682 StoreStubCompiler compiler(extra_ic_state); | 682 StoreStubCompiler compiler(strict_mode); |
| 683 { MaybeObject* maybe_code = | 683 { MaybeObject* maybe_code = |
| 684 compiler.CompileStoreCallback(receiver, callback, name); | 684 compiler.CompileStoreCallback(receiver, callback, name); |
| 685 if (!maybe_code->ToObject(&code)) return maybe_code; | 685 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 686 } | 686 } |
| 687 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 687 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 688 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); | 688 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 689 Object* result; | 689 Object* result; |
| 690 { MaybeObject* maybe_result = | 690 { MaybeObject* maybe_result = |
| 691 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 691 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 692 if (!maybe_result->ToObject(&result)) return maybe_result; | 692 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 return code; | 695 return code; |
| 696 } | 696 } |
| 697 | 697 |
| 698 | 698 |
| 699 MaybeObject* StubCache::ComputeStoreInterceptor( | 699 MaybeObject* StubCache::ComputeStoreInterceptor( |
| 700 String* name, | 700 String* name, |
| 701 JSObject* receiver, | 701 JSObject* receiver, |
| 702 Code::ExtraICState extra_ic_state) { | 702 StrictModeFlag strict_mode) { |
| 703 Code::Flags flags = Code::ComputeMonomorphicFlags( | 703 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 704 Code::STORE_IC, INTERCEPTOR, extra_ic_state); | 704 Code::STORE_IC, INTERCEPTOR, strict_mode); |
| 705 Object* code = receiver->map()->FindInCodeCache(name, flags); | 705 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 706 if (code->IsUndefined()) { | 706 if (code->IsUndefined()) { |
| 707 StoreStubCompiler compiler(extra_ic_state); | 707 StoreStubCompiler compiler(strict_mode); |
| 708 { MaybeObject* maybe_code = | 708 { MaybeObject* maybe_code = |
| 709 compiler.CompileStoreInterceptor(receiver, name); | 709 compiler.CompileStoreInterceptor(receiver, name); |
| 710 if (!maybe_code->ToObject(&code)) return maybe_code; | 710 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 711 } | 711 } |
| 712 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); | 712 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); |
| 713 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); | 713 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code))); |
| 714 Object* result; | 714 Object* result; |
| 715 { MaybeObject* maybe_result = | 715 { MaybeObject* maybe_result = |
| 716 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 716 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 717 if (!maybe_result->ToObject(&result)) return maybe_result; | 717 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 718 } | 718 } |
| 719 } | 719 } |
| 720 return code; | 720 return code; |
| 721 } | 721 } |
| 722 | 722 |
| 723 | 723 |
| 724 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, | 724 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, |
| 725 JSObject* receiver, | 725 JSObject* receiver, |
| 726 int field_index, | 726 int field_index, |
| 727 Map* transition) { | 727 Map* transition, |
| 728 StrictModeFlag strict_mode) { |
| 728 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 729 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 729 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 730 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 731 Code::KEYED_STORE_IC, type, strict_mode); |
| 730 Object* code = receiver->map()->FindInCodeCache(name, flags); | 732 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 731 if (code->IsUndefined()) { | 733 if (code->IsUndefined()) { |
| 732 KeyedStoreStubCompiler compiler; | 734 KeyedStoreStubCompiler compiler(strict_mode); |
| 733 { MaybeObject* maybe_code = | 735 { MaybeObject* maybe_code = |
| 734 compiler.CompileStoreField(receiver, field_index, transition, name); | 736 compiler.CompileStoreField(receiver, field_index, transition, name); |
| 735 if (!maybe_code->ToObject(&code)) return maybe_code; | 737 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 736 } | 738 } |
| 737 PROFILE(CodeCreateEvent( | 739 PROFILE(CodeCreateEvent( |
| 738 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); | 740 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); |
| 739 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code))); | 741 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code))); |
| 740 Object* result; | 742 Object* result; |
| 741 { MaybeObject* maybe_result = | 743 { MaybeObject* maybe_result = |
| 742 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 744 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1410 MaybeObject* result = LoadWithInterceptor(&args, &attr); | 1412 MaybeObject* result = LoadWithInterceptor(&args, &attr); |
| 1411 RETURN_IF_SCHEDULED_EXCEPTION(); | 1413 RETURN_IF_SCHEDULED_EXCEPTION(); |
| 1412 // This is call IC. In this case, we simply return the undefined result which | 1414 // This is call IC. In this case, we simply return the undefined result which |
| 1413 // will lead to an exception when trying to invoke the result as a | 1415 // will lead to an exception when trying to invoke the result as a |
| 1414 // function. | 1416 // function. |
| 1415 return result; | 1417 return result; |
| 1416 } | 1418 } |
| 1417 | 1419 |
| 1418 | 1420 |
| 1419 MaybeObject* StoreInterceptorProperty(Arguments args) { | 1421 MaybeObject* StoreInterceptorProperty(Arguments args) { |
| 1422 ASSERT(args.length() == 4); |
| 1420 JSObject* recv = JSObject::cast(args[0]); | 1423 JSObject* recv = JSObject::cast(args[0]); |
| 1421 String* name = String::cast(args[1]); | 1424 String* name = String::cast(args[1]); |
| 1422 Object* value = args[2]; | 1425 Object* value = args[2]; |
| 1426 StrictModeFlag strict_mode = |
| 1427 static_cast<StrictModeFlag>(Smi::cast(args[3])->value()); |
| 1428 ASSERT(strict_mode == kStrictMode || strict_mode == kNonStrictMode); |
| 1423 ASSERT(recv->HasNamedInterceptor()); | 1429 ASSERT(recv->HasNamedInterceptor()); |
| 1424 PropertyAttributes attr = NONE; | 1430 PropertyAttributes attr = NONE; |
| 1425 MaybeObject* result = recv->SetPropertyWithInterceptor(name, value, attr); | 1431 MaybeObject* result = recv->SetPropertyWithInterceptor( |
| 1432 name, value, attr, strict_mode); |
| 1426 return result; | 1433 return result; |
| 1427 } | 1434 } |
| 1428 | 1435 |
| 1429 | 1436 |
| 1430 MaybeObject* KeyedLoadPropertyWithInterceptor(Arguments args) { | 1437 MaybeObject* KeyedLoadPropertyWithInterceptor(Arguments args) { |
| 1431 JSObject* receiver = JSObject::cast(args[0]); | 1438 JSObject* receiver = JSObject::cast(args[0]); |
| 1432 ASSERT(Smi::cast(args[1])->value() >= 0); | 1439 ASSERT(Smi::cast(args[1])->value() >= 0); |
| 1433 uint32_t index = Smi::cast(args[1])->value(); | 1440 uint32_t index = Smi::cast(args[1])->value(); |
| 1434 return receiver->GetElementWithInterceptor(receiver, index); | 1441 return receiver->GetElementWithInterceptor(receiver, index); |
| 1435 } | 1442 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 name)); | 1675 name)); |
| 1669 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, | 1676 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, |
| 1670 name, | 1677 name, |
| 1671 Code::cast(result->ToObjectUnchecked()))); | 1678 Code::cast(result->ToObjectUnchecked()))); |
| 1672 } | 1679 } |
| 1673 return result; | 1680 return result; |
| 1674 } | 1681 } |
| 1675 | 1682 |
| 1676 | 1683 |
| 1677 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { | 1684 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1678 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type, | 1685 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 1679 extra_ic_state_); | 1686 Code::STORE_IC, type, strict_mode_); |
| 1680 MaybeObject* result = GetCodeWithFlags(flags, name); | 1687 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1681 if (!result->IsFailure()) { | 1688 if (!result->IsFailure()) { |
| 1682 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, | 1689 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, |
| 1683 Code::cast(result->ToObjectUnchecked()), | 1690 Code::cast(result->ToObjectUnchecked()), |
| 1684 name)); | 1691 name)); |
| 1685 GDBJIT(AddCode(GDBJITInterface::STORE_IC, | 1692 GDBJIT(AddCode(GDBJITInterface::STORE_IC, |
| 1686 name, | 1693 name, |
| 1687 Code::cast(result->ToObjectUnchecked()))); | 1694 Code::cast(result->ToObjectUnchecked()))); |
| 1688 } | 1695 } |
| 1689 return result; | 1696 return result; |
| 1690 } | 1697 } |
| 1691 | 1698 |
| 1692 | 1699 |
| 1693 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { | 1700 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 1694 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 1701 Code::Flags flags = Code::ComputeMonomorphicFlags( |
| 1702 Code::KEYED_STORE_IC, type, strict_mode_); |
| 1695 MaybeObject* result = GetCodeWithFlags(flags, name); | 1703 MaybeObject* result = GetCodeWithFlags(flags, name); |
| 1696 if (!result->IsFailure()) { | 1704 if (!result->IsFailure()) { |
| 1697 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, | 1705 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, |
| 1698 Code::cast(result->ToObjectUnchecked()), | 1706 Code::cast(result->ToObjectUnchecked()), |
| 1699 name)); | 1707 name)); |
| 1700 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, | 1708 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, |
| 1701 name, | 1709 name, |
| 1702 Code::cast(result->ToObjectUnchecked()))); | 1710 Code::cast(result->ToObjectUnchecked()))); |
| 1703 } | 1711 } |
| 1704 return result; | 1712 return result; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1855 if (!maybe_result->ToObject(&result)) return maybe_result; | 1863 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1856 } | 1864 } |
| 1857 Code* code = Code::cast(result); | 1865 Code* code = Code::cast(result); |
| 1858 USE(code); | 1866 USE(code); |
| 1859 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); | 1867 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); |
| 1860 return result; | 1868 return result; |
| 1861 } | 1869 } |
| 1862 | 1870 |
| 1863 | 1871 |
| 1864 } } // namespace v8::internal | 1872 } } // namespace v8::internal |
| OLD | NEW |