Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { | 491 Handle<Code> StubCache::ComputeStoreNormal(StrictModeFlag strict_mode) { |
| 492 return (strict_mode == kStrictMode) | 492 return (strict_mode == kStrictMode) |
| 493 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() | 493 ? isolate_->builtins()->Builtins::StoreIC_Normal_Strict() |
| 494 : isolate_->builtins()->Builtins::StoreIC_Normal(); | 494 : isolate_->builtins()->Builtins::StoreIC_Normal(); |
| 495 } | 495 } |
| 496 | 496 |
| 497 | 497 |
| 498 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, | 498 Handle<Code> StubCache::ComputeStoreGlobal(Handle<Name> name, |
| 499 Handle<GlobalObject> receiver, | 499 Handle<GlobalObject> receiver, |
| 500 Handle<PropertyCell> cell, | 500 Handle<PropertyCell> cell, |
| 501 Handle<Object> value, | |
| 501 StrictModeFlag strict_mode) { | 502 StrictModeFlag strict_mode) { |
| 502 Handle<Code> stub = FindIC( | 503 Isolate* isolate = cell->GetIsolate(); |
| 504 Handle<Type> union_type(cell->UpdateType(*value), isolate); | |
| 505 bool is_constant = union_type->IsConstant(); | |
| 506 StoreGlobalStub stub(strict_mode, is_constant); | |
| 507 | |
| 508 Handle<Code> code = FindIC( | |
| 503 name, Handle<JSObject>::cast(receiver), | 509 name, Handle<JSObject>::cast(receiver), |
| 504 Code::STORE_IC, Code::NORMAL, strict_mode); | 510 Code::STORE_IC, Code::NORMAL, stub.GetExtraICState()); |
| 505 if (!stub.is_null()) return stub; | 511 if (!code.is_null()) return code; |
| 506 | 512 |
| 507 StoreStubCompiler compiler(isolate_, strict_mode); | 513 if (is_constant) return stub.GetCode(isolate_); |
| 508 Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name); | 514 |
| 515 // Replace the placeholder cell and global object map with the actual global | |
| 516 // cell and receiver map. | |
| 517 Handle<Map> cell_map(isolate_->heap()->global_property_cell_map()); | |
| 518 Handle<Map> meta_map(isolate_->heap()->meta_map()); | |
| 519 Handle<Object> receiver_map(receiver->map(), isolate_); | |
| 520 code = stub.GetCodeCopyFromTemplate(isolate_); | |
| 521 code->ReplaceNthObject(1, *meta_map, *receiver_map); | |
| 522 code->ReplaceNthObject(1, *cell_map, *cell); | |
|
ulan
2013/07/01 11:35:03
I didn't get this part. Where in the generated cod
danno
2013/07/01 12:52:23
The idea behind code templates is that you create
| |
| 509 JSObject::UpdateMapCodeCache(receiver, name, code); | 523 JSObject::UpdateMapCodeCache(receiver, name, code); |
| 524 | |
| 510 return code; | 525 return code; |
| 511 } | 526 } |
| 512 | 527 |
| 513 | 528 |
| 514 Handle<Code> StubCache::ComputeStoreCallback( | 529 Handle<Code> StubCache::ComputeStoreCallback( |
| 515 Handle<Name> name, | 530 Handle<Name> name, |
| 516 Handle<JSObject> receiver, | 531 Handle<JSObject> receiver, |
| 517 Handle<JSObject> holder, | 532 Handle<JSObject> holder, |
| 518 Handle<ExecutableAccessorInfo> callback, | 533 Handle<ExecutableAccessorInfo> callback, |
| 519 StrictModeFlag strict_mode) { | 534 StrictModeFlag strict_mode) { |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 | 929 |
| 915 Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, | 930 Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, |
| 916 CompareNilICStub& stub) { | 931 CompareNilICStub& stub) { |
| 917 Handle<String> name(isolate_->heap()->empty_string()); | 932 Handle<String> name(isolate_->heap()->empty_string()); |
| 918 if (!receiver_map->is_shared()) { | 933 if (!receiver_map->is_shared()) { |
| 919 Handle<Code> cached_ic = FindIC(name, receiver_map, Code::COMPARE_NIL_IC, | 934 Handle<Code> cached_ic = FindIC(name, receiver_map, Code::COMPARE_NIL_IC, |
| 920 Code::NORMAL, stub.GetExtraICState()); | 935 Code::NORMAL, stub.GetExtraICState()); |
| 921 if (!cached_ic.is_null()) return cached_ic; | 936 if (!cached_ic.is_null()) return cached_ic; |
| 922 } | 937 } |
| 923 | 938 |
| 924 Handle<Code> ic = stub.GetCode(isolate_); | 939 Handle<Code> ic = stub.GetCodeCopyFromTemplate(isolate_); |
| 925 | 940 ic->ReplaceNthObject(1, isolate_->heap()->meta_map(), *receiver_map); |
| 926 // For monomorphic maps, use the code as a template, copying and replacing | |
| 927 // the monomorphic map that checks the object's type. | |
| 928 ic = isolate_->factory()->CopyCode(ic); | |
| 929 ic->ReplaceFirstMap(*receiver_map); | |
| 930 | 941 |
| 931 if (!receiver_map->is_shared()) { | 942 if (!receiver_map->is_shared()) { |
| 932 Map::UpdateCodeCache(receiver_map, name, ic); | 943 Map::UpdateCodeCache(receiver_map, name, ic); |
| 933 } | 944 } |
| 934 | 945 |
| 935 return ic; | 946 return ic; |
| 936 } | 947 } |
| 937 | 948 |
| 938 | 949 |
| 939 Handle<Code> StubCache::ComputeLoadElementPolymorphic( | 950 Handle<Code> StubCache::ComputeLoadElementPolymorphic( |
| (...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2099 Handle<FunctionTemplateInfo>( | 2110 Handle<FunctionTemplateInfo>( |
| 2100 FunctionTemplateInfo::cast(signature->receiver())); | 2111 FunctionTemplateInfo::cast(signature->receiver())); |
| 2101 } | 2112 } |
| 2102 } | 2113 } |
| 2103 | 2114 |
| 2104 is_simple_api_call_ = true; | 2115 is_simple_api_call_ = true; |
| 2105 } | 2116 } |
| 2106 | 2117 |
| 2107 | 2118 |
| 2108 } } // namespace v8::internal | 2119 } } // namespace v8::internal |
| OLD | NEW |