| 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 Object* result; | 500 Object* result; |
| 501 { MaybeObject* maybe_result = | 501 { MaybeObject* maybe_result = |
| 502 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 502 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 503 if (!maybe_result->ToObject(&result)) return maybe_result; | 503 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 return code; | 506 return code; |
| 507 } | 507 } |
| 508 | 508 |
| 509 | 509 |
| 510 namespace { | |
| 511 | |
| 512 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { | |
| 513 switch (kind) { | |
| 514 case JSObject::EXTERNAL_BYTE_ELEMENTS: | |
| 515 return kExternalByteArray; | |
| 516 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
| 517 return kExternalUnsignedByteArray; | |
| 518 case JSObject::EXTERNAL_SHORT_ELEMENTS: | |
| 519 return kExternalShortArray; | |
| 520 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
| 521 return kExternalUnsignedShortArray; | |
| 522 case JSObject::EXTERNAL_INT_ELEMENTS: | |
| 523 return kExternalIntArray; | |
| 524 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
| 525 return kExternalUnsignedIntArray; | |
| 526 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | |
| 527 return kExternalFloatArray; | |
| 528 default: | |
| 529 UNREACHABLE(); | |
| 530 return static_cast<ExternalArrayType>(0); | |
| 531 } | |
| 532 } | |
| 533 | |
| 534 } // anonymous namespace | |
| 535 | |
| 536 | |
| 537 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( | |
| 538 JSObject* receiver, | |
| 539 bool is_store) { | |
| 540 Code::Flags flags = | |
| 541 Code::ComputeMonomorphicFlags( | |
| 542 is_store ? Code::KEYED_STORE_IC : Code::KEYED_LOAD_IC, | |
| 543 NORMAL); | |
| 544 ExternalArrayType array_type = | |
| 545 ElementsKindToExternalArrayType(receiver->GetElementsKind()); | |
| 546 String* name = | |
| 547 is_store ? Heap::KeyedStoreExternalArray_symbol() | |
| 548 : Heap::KeyedLoadExternalArray_symbol(); | |
| 549 // Use the global maps for the particular external array types, | |
| 550 // rather than the receiver's map, when looking up the cached code, | |
| 551 // so that we actually canonicalize these stubs. | |
| 552 Map* map = Heap::MapForExternalArrayType(array_type); | |
| 553 Object* code = map->FindInCodeCache(name, flags); | |
| 554 if (code->IsUndefined()) { | |
| 555 ExternalArrayStubCompiler compiler; | |
| 556 { MaybeObject* maybe_code = | |
| 557 is_store ? compiler.CompileKeyedStoreStub(array_type, flags) : | |
| 558 compiler.CompileKeyedLoadStub(array_type, flags); | |
| 559 if (!maybe_code->ToObject(&code)) return maybe_code; | |
| 560 } | |
| 561 if (is_store) { | |
| 562 PROFILE( | |
| 563 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, Code::cast(code), 0)); | |
| 564 } else { | |
| 565 PROFILE( | |
| 566 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | |
| 567 } | |
| 568 Object* result; | |
| 569 { MaybeObject* maybe_result = | |
| 570 map->UpdateCodeCache(name, Code::cast(code)); | |
| 571 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 572 } | |
| 573 } | |
| 574 return code; | |
| 575 } | |
| 576 | |
| 577 | |
| 578 MaybeObject* StubCache::ComputeStoreNormal() { | 510 MaybeObject* StubCache::ComputeStoreNormal() { |
| 579 return Builtins::builtin(Builtins::StoreIC_Normal); | 511 return Builtins::builtin(Builtins::StoreIC_Normal); |
| 580 } | 512 } |
| 581 | 513 |
| 582 | 514 |
| 583 MaybeObject* StubCache::ComputeStoreGlobal(String* name, | 515 MaybeObject* StubCache::ComputeStoreGlobal(String* name, |
| 584 GlobalObject* receiver, | 516 GlobalObject* receiver, |
| 585 JSGlobalPropertyCell* cell) { | 517 JSGlobalPropertyCell* cell) { |
| 586 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); | 518 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); |
| 587 Object* code = receiver->map()->FindInCodeCache(name, flags); | 519 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 if (!signature->receiver()->IsUndefined()) { | 1702 if (!signature->receiver()->IsUndefined()) { |
| 1771 expected_receiver_type_ = | 1703 expected_receiver_type_ = |
| 1772 FunctionTemplateInfo::cast(signature->receiver()); | 1704 FunctionTemplateInfo::cast(signature->receiver()); |
| 1773 } | 1705 } |
| 1774 } | 1706 } |
| 1775 | 1707 |
| 1776 is_simple_api_call_ = true; | 1708 is_simple_api_call_ = true; |
| 1777 } | 1709 } |
| 1778 | 1710 |
| 1779 | 1711 |
| 1780 MaybeObject* ExternalArrayStubCompiler::GetCode(Code::Flags flags) { | |
| 1781 Object* result; | |
| 1782 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ExternalArrayStub"); | |
| 1783 if (!maybe_result->ToObject(&result)) return maybe_result; | |
| 1784 } | |
| 1785 Code* code = Code::cast(result); | |
| 1786 USE(code); | |
| 1787 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); | |
| 1788 return result; | |
| 1789 } | |
| 1790 | |
| 1791 | |
| 1792 } } // namespace v8::internal | 1712 } } // namespace v8::internal |
| OLD | NEW |