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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 Object* result; | 478 Object* result; |
479 { MaybeObject* maybe_result = | 479 { MaybeObject* maybe_result = |
480 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 480 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
481 if (!maybe_result->ToObject(&result)) return maybe_result; | 481 if (!maybe_result->ToObject(&result)) return maybe_result; |
482 } | 482 } |
483 } | 483 } |
484 return code; | 484 return code; |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 namespace { | 488 MaybeObject* StubCache::ComputeKeyedLoadOrStoreElement( |
489 | |
490 ExternalArrayType ElementsKindToExternalArrayType(JSObject::ElementsKind kind) { | |
491 switch (kind) { | |
492 case JSObject::EXTERNAL_BYTE_ELEMENTS: | |
493 return kExternalByteArray; | |
494 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
495 return kExternalUnsignedByteArray; | |
496 case JSObject::EXTERNAL_SHORT_ELEMENTS: | |
497 return kExternalShortArray; | |
498 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
499 return kExternalUnsignedShortArray; | |
500 case JSObject::EXTERNAL_INT_ELEMENTS: | |
501 return kExternalIntArray; | |
502 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
503 return kExternalUnsignedIntArray; | |
504 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | |
505 return kExternalFloatArray; | |
506 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: | |
507 return kExternalDoubleArray; | |
508 case JSObject::EXTERNAL_PIXEL_ELEMENTS: | |
509 return kExternalPixelArray; | |
510 default: | |
511 UNREACHABLE(); | |
512 return static_cast<ExternalArrayType>(0); | |
513 } | |
514 } | |
515 | |
516 } // anonymous namespace | |
517 | |
518 | |
519 MaybeObject* StubCache::ComputeKeyedLoadOrStoreExternalArray( | |
520 JSObject* receiver, | 489 JSObject* receiver, |
521 bool is_store, | 490 bool is_store, |
522 StrictModeFlag strict_mode) { | 491 StrictModeFlag strict_mode) { |
523 Code::Flags flags = | 492 Code::Flags flags = |
524 Code::ComputeMonomorphicFlags( | 493 Code::ComputeMonomorphicFlags( |
525 is_store ? Code::KEYED_STORE_IC : | 494 is_store ? Code::KEYED_STORE_IC : |
526 Code::KEYED_LOAD_IC, | 495 Code::KEYED_LOAD_IC, |
527 NORMAL, | 496 NORMAL, |
528 strict_mode); | 497 strict_mode); |
529 ExternalArrayType array_type = | |
530 ElementsKindToExternalArrayType(receiver->GetElementsKind()); | |
531 String* name = is_store | |
532 ? isolate()->heap()->KeyedStoreSpecializedMonomorphic_symbol() | |
533 : isolate()->heap()->KeyedLoadSpecializedMonomorphic_symbol(); | |
534 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags); | |
535 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code); | |
536 | |
537 MaybeObject* maybe_new_code = NULL; | |
538 if (is_store) { | |
539 ExternalArrayStoreStubCompiler compiler(strict_mode); | |
540 maybe_new_code = compiler.CompileStore(receiver, array_type); | |
541 } else { | |
542 ExternalArrayLoadStubCompiler compiler(strict_mode); | |
543 maybe_new_code = compiler.CompileLoad(receiver, array_type); | |
544 } | |
545 Code* code; | |
546 if (!maybe_new_code->To(&code)) return maybe_new_code; | |
547 code->set_external_array_type(array_type); | |
548 if (is_store) { | |
549 PROFILE(isolate_, | |
550 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, | |
551 Code::cast(code), 0)); | |
552 } else { | |
553 PROFILE(isolate_, | |
554 CodeCreateEvent(Logger::KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, | |
555 Code::cast(code), 0)); | |
556 } | |
557 ASSERT(code->IsCode()); | |
558 Object* result; | |
559 { MaybeObject* maybe_result = | |
560 receiver->UpdateMapCodeCache(name, Code::cast(code)); | |
561 if (!maybe_result->ToObject(&result)) return maybe_result; | |
562 } | |
563 return code; | |
564 } | |
565 | |
566 | |
567 MaybeObject* StubCache::ComputeKeyedLoadOrStoreFastElement( | |
568 JSObject* receiver, | |
569 bool is_store, | |
570 StrictModeFlag strict_mode) { | |
571 Code::Flags flags = | |
572 Code::ComputeMonomorphicFlags( | |
573 is_store ? Code::KEYED_STORE_IC : | |
574 Code::KEYED_LOAD_IC, | |
575 NORMAL, | |
576 strict_mode); | |
577 String* name = is_store | 498 String* name = is_store |
578 ? isolate()->heap()->KeyedStoreSpecializedMonomorphic_symbol() | 499 ? isolate()->heap()->KeyedStoreElementMonomorphic_symbol() |
579 : isolate()->heap()->KeyedLoadSpecializedMonomorphic_symbol(); | 500 : isolate()->heap()->KeyedLoadElementMonomorphic_symbol(); |
580 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags); | 501 Object* maybe_code = receiver->map()->FindInCodeCache(name, flags); |
581 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code); | 502 if (!maybe_code->IsUndefined()) return Code::cast(maybe_code); |
582 | 503 |
583 MaybeObject* maybe_new_code = NULL; | 504 MaybeObject* maybe_new_code = NULL; |
584 if (is_store) { | 505 if (is_store) { |
585 KeyedStoreStubCompiler compiler(strict_mode); | 506 KeyedStoreStubCompiler compiler(strict_mode); |
586 maybe_new_code = compiler.CompileStoreFastElement(receiver->map()); | 507 maybe_new_code = compiler.CompileStoreElement(receiver->map()); |
587 } else { | 508 } else { |
588 KeyedLoadStubCompiler compiler; | 509 KeyedLoadStubCompiler compiler; |
589 maybe_new_code = compiler.CompileLoadFastElement(receiver->map()); | 510 maybe_new_code = compiler.CompileLoadElement(receiver->map()); |
590 } | 511 } |
591 Code* code; | 512 Code* code; |
592 if (!maybe_new_code->To(&code)) return maybe_new_code; | 513 if (!maybe_new_code->To(&code)) return maybe_new_code; |
593 if (is_store) { | 514 if (is_store) { |
594 PROFILE(isolate_, | 515 PROFILE(isolate_, |
595 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, | 516 CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, |
596 Code::cast(code), 0)); | 517 Code::cast(code), 0)); |
597 } else { | 518 } else { |
598 PROFILE(isolate_, | 519 PROFILE(isolate_, |
599 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, | 520 CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 if (!signature->receiver()->IsUndefined()) { | 1837 if (!signature->receiver()->IsUndefined()) { |
1917 expected_receiver_type_ = | 1838 expected_receiver_type_ = |
1918 FunctionTemplateInfo::cast(signature->receiver()); | 1839 FunctionTemplateInfo::cast(signature->receiver()); |
1919 } | 1840 } |
1920 } | 1841 } |
1921 | 1842 |
1922 is_simple_api_call_ = true; | 1843 is_simple_api_call_ = true; |
1923 } | 1844 } |
1924 | 1845 |
1925 | 1846 |
1926 MaybeObject* ExternalArrayLoadStubCompiler::GetCode() { | |
1927 Object* result; | |
1928 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, | |
1929 NORMAL, | |
1930 strict_mode_); | |
1931 { MaybeObject* maybe_result = GetCodeWithFlags(flags, | |
1932 "ExternalArrayLoadStub"); | |
1933 if (!maybe_result->ToObject(&result)) return maybe_result; | |
1934 } | |
1935 Code* code = Code::cast(result); | |
1936 USE(code); | |
1937 PROFILE(isolate(), | |
1938 CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayLoadStub")); | |
1939 return result; | |
1940 } | |
1941 | |
1942 | |
1943 MaybeObject* ExternalArrayStoreStubCompiler::GetCode() { | |
1944 Object* result; | |
1945 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, | |
1946 NORMAL, | |
1947 strict_mode_); | |
1948 { MaybeObject* maybe_result = GetCodeWithFlags(flags, | |
1949 "ExternalArrayStoreStub"); | |
1950 if (!maybe_result->ToObject(&result)) return maybe_result; | |
1951 } | |
1952 Code* code = Code::cast(result); | |
1953 USE(code); | |
1954 PROFILE(isolate(), | |
1955 CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStoreStub")); | |
1956 return result; | |
1957 } | |
1958 | |
1959 | |
1960 } } // namespace v8::internal | 1847 } } // namespace v8::internal |
OLD | NEW |