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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 { MaybeObject* maybe_result = | 434 { MaybeObject* maybe_result = |
435 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 435 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
436 if (!maybe_result->ToObject(&result)) return maybe_result; | 436 if (!maybe_result->ToObject(&result)) return maybe_result; |
437 } | 437 } |
438 } | 438 } |
439 return code; | 439 return code; |
440 } | 440 } |
441 | 441 |
442 | 442 |
443 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { | 443 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { |
| 444 // Using NORMAL as the PropertyType for array element loads is a misuse. The |
| 445 // generated stub always accesses fast elements, not slow-mode fields, but |
| 446 // some property type is required for the stub lookup. Note that overloading |
| 447 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 448 // other keyed field loads. This is guaranteed to be the case since all field |
| 449 // keyed loads that are not array elements go through a generic builtin stub. |
444 Code::Flags flags = | 450 Code::Flags flags = |
445 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); | 451 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); |
446 String* name = Heap::KeyedLoadSpecialized_symbol(); | 452 String* name = Heap::KeyedLoadSpecialized_symbol(); |
447 Object* code = receiver->map()->FindInCodeCache(name, flags); | 453 Object* code = receiver->map()->FindInCodeCache(name, flags); |
448 if (code->IsUndefined()) { | 454 if (code->IsUndefined()) { |
449 KeyedLoadStubCompiler compiler; | 455 KeyedLoadStubCompiler compiler; |
450 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); | 456 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); |
451 if (!maybe_code->ToObject(&code)) return maybe_code; | 457 if (!maybe_code->ToObject(&code)) return maybe_code; |
452 } | 458 } |
453 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | 459 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
454 Object* result; | 460 Object* result; |
455 { MaybeObject* maybe_result = | 461 { MaybeObject* maybe_result = |
456 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 462 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
457 if (!maybe_result->ToObject(&result)) return maybe_result; | 463 if (!maybe_result->ToObject(&result)) return maybe_result; |
458 } | 464 } |
459 } | 465 } |
460 return code; | 466 return code; |
461 } | 467 } |
462 | 468 |
463 | 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 |
464 MaybeObject* StubCache::ComputeStoreField(String* name, | 497 MaybeObject* StubCache::ComputeStoreField(String* name, |
465 JSObject* receiver, | 498 JSObject* receiver, |
466 int field_index, | 499 int field_index, |
467 Map* transition) { | 500 Map* transition) { |
468 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 501 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
469 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 502 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); |
470 Object* code = receiver->map()->FindInCodeCache(name, flags); | 503 Object* code = receiver->map()->FindInCodeCache(name, flags); |
471 if (code->IsUndefined()) { | 504 if (code->IsUndefined()) { |
472 StoreStubCompiler compiler; | 505 StoreStubCompiler compiler; |
473 { MaybeObject* maybe_code = | 506 { MaybeObject* maybe_code = |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1783 if (!maybe_result->ToObject(&result)) return maybe_result; | 1816 if (!maybe_result->ToObject(&result)) return maybe_result; |
1784 } | 1817 } |
1785 Code* code = Code::cast(result); | 1818 Code* code = Code::cast(result); |
1786 USE(code); | 1819 USE(code); |
1787 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); | 1820 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); |
1788 return result; | 1821 return result; |
1789 } | 1822 } |
1790 | 1823 |
1791 | 1824 |
1792 } } // namespace v8::internal | 1825 } } // namespace v8::internal |
OLD | NEW |