| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 { MaybeObject* maybe_result = | 438 { MaybeObject* maybe_result = |
| 439 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 439 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 440 if (!maybe_result->ToObject(&result)) return maybe_result; | 440 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 441 } | 441 } |
| 442 } | 442 } |
| 443 return code; | 443 return code; |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { | 447 MaybeObject* StubCache::ComputeKeyedLoadSpecialized(JSObject* receiver) { |
| 448 // Using NORMAL as the PropertyType for array element loads is a misuse. The |
| 449 // generated stub always accesses fast elements, not slow-mode fields, but |
| 450 // some property type is required for the stub lookup. Note that overloading |
| 451 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 452 // other keyed field loads. This is guaranteed to be the case since all field |
| 453 // keyed loads that are not array elements go through a generic builtin stub. |
| 448 Code::Flags flags = | 454 Code::Flags flags = |
| 449 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); | 455 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); |
| 450 String* name = isolate_->heap()->KeyedLoadSpecialized_symbol(); | 456 String* name = isolate_->heap()->KeyedLoadSpecialized_symbol(); |
| 451 Object* code = receiver->map()->FindInCodeCache(name, flags); | 457 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 452 if (code->IsUndefined()) { | 458 if (code->IsUndefined()) { |
| 453 KeyedLoadStubCompiler compiler; | 459 KeyedLoadStubCompiler compiler; |
| 454 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); | 460 { MaybeObject* maybe_code = compiler.CompileLoadSpecialized(receiver); |
| 455 if (!maybe_code->ToObject(&code)) return maybe_code; | 461 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 456 } | 462 } |
| 457 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); | 463 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 458 Object* result; | 464 Object* result; |
| 459 { MaybeObject* maybe_result = | 465 { MaybeObject* maybe_result = |
| 460 receiver->UpdateMapCodeCache(name, Code::cast(code)); | 466 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 461 if (!maybe_result->ToObject(&result)) return maybe_result; | 467 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 462 } | 468 } |
| 463 } | 469 } |
| 464 return code; | 470 return code; |
| 465 } | 471 } |
| 466 | 472 |
| 467 | 473 |
| 474 MaybeObject* StubCache::ComputeKeyedLoadPixelArray(JSObject* receiver) { |
| 475 // Using NORMAL as the PropertyType for array element loads is a misuse. The |
| 476 // generated stub always accesses fast elements, not slow-mode fields, but |
| 477 // some property type is required for the stub lookup. Note that overloading |
| 478 // the NORMAL PropertyType is only safe as long as no stubs are generated for |
| 479 // other keyed field loads. This is guaranteed to be the case since all field |
| 480 // keyed loads that are not array elements go through a generic builtin stub. |
| 481 Code::Flags flags = |
| 482 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, NORMAL); |
| 483 String* name = isolate_->heap()->KeyedLoadPixelArray_symbol(); |
| 484 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 485 if (code->IsUndefined()) { |
| 486 KeyedLoadStubCompiler compiler; |
| 487 { MaybeObject* maybe_code = compiler.CompileLoadPixelArray(receiver); |
| 488 if (!maybe_code->ToObject(&code)) return maybe_code; |
| 489 } |
| 490 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), 0)); |
| 491 Object* result; |
| 492 { MaybeObject* maybe_result = |
| 493 receiver->UpdateMapCodeCache(name, Code::cast(code)); |
| 494 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 495 } |
| 496 } |
| 497 return code; |
| 498 } |
| 499 |
| 500 |
| 468 MaybeObject* StubCache::ComputeStoreField(String* name, | 501 MaybeObject* StubCache::ComputeStoreField(String* name, |
| 469 JSObject* receiver, | 502 JSObject* receiver, |
| 470 int field_index, | 503 int field_index, |
| 471 Map* transition) { | 504 Map* transition) { |
| 472 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; | 505 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; |
| 473 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); | 506 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); |
| 474 Object* code = receiver->map()->FindInCodeCache(name, flags); | 507 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 475 if (code->IsUndefined()) { | 508 if (code->IsUndefined()) { |
| 476 StoreStubCompiler compiler; | 509 StoreStubCompiler compiler; |
| 477 { MaybeObject* maybe_code = | 510 { MaybeObject* maybe_code = |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 if (!maybe_result->ToObject(&result)) return maybe_result; | 1835 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 1803 } | 1836 } |
| 1804 Code* code = Code::cast(result); | 1837 Code* code = Code::cast(result); |
| 1805 USE(code); | 1838 USE(code); |
| 1806 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); | 1839 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ExternalArrayStub")); |
| 1807 return result; | 1840 return result; |
| 1808 } | 1841 } |
| 1809 | 1842 |
| 1810 | 1843 |
| 1811 } } // namespace v8::internal | 1844 } } // namespace v8::internal |
| OLD | NEW |