| 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->union_type(*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 if (!is_constant) { |
| 522 code->ReplaceNthObject(1, *meta_map, *receiver_map); |
| 523 code->ReplaceNthObject(1, *cell_map, *cell); |
| 524 } |
| 509 JSObject::UpdateMapCodeCache(receiver, name, code); | 525 JSObject::UpdateMapCodeCache(receiver, name, code); |
| 510 return code; | 526 return code; |
| 511 } | 527 } |
| 512 | 528 |
| 513 | 529 |
| 514 Handle<Code> StubCache::ComputeStoreCallback( | 530 Handle<Code> StubCache::ComputeStoreCallback( |
| 515 Handle<Name> name, | 531 Handle<Name> name, |
| 516 Handle<JSObject> receiver, | 532 Handle<JSObject> receiver, |
| 517 Handle<JSObject> holder, | 533 Handle<JSObject> holder, |
| 518 Handle<ExecutableAccessorInfo> callback, | 534 Handle<ExecutableAccessorInfo> callback, |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 925 |
| 910 Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, | 926 Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map, |
| 911 CompareNilICStub& stub) { | 927 CompareNilICStub& stub) { |
| 912 Handle<String> name(isolate_->heap()->empty_string()); | 928 Handle<String> name(isolate_->heap()->empty_string()); |
| 913 if (!receiver_map->is_shared()) { | 929 if (!receiver_map->is_shared()) { |
| 914 Handle<Code> cached_ic = FindIC(name, receiver_map, Code::COMPARE_NIL_IC, | 930 Handle<Code> cached_ic = FindIC(name, receiver_map, Code::COMPARE_NIL_IC, |
| 915 Code::NORMAL, stub.GetExtraICState()); | 931 Code::NORMAL, stub.GetExtraICState()); |
| 916 if (!cached_ic.is_null()) return cached_ic; | 932 if (!cached_ic.is_null()) return cached_ic; |
| 917 } | 933 } |
| 918 | 934 |
| 919 Handle<Code> ic = stub.GetCode(isolate_); | 935 Handle<Code> ic = stub.GetCodeCopyFromTemplate(isolate_); |
| 920 | 936 ic->ReplaceNthObject(1, isolate_->heap()->meta_map(), *receiver_map); |
| 921 // For monomorphic maps, use the code as a template, copying and replacing | |
| 922 // the monomorphic map that checks the object's type. | |
| 923 ic = isolate_->factory()->CopyCode(ic); | |
| 924 ic->ReplaceFirstMap(*receiver_map); | |
| 925 | 937 |
| 926 if (!receiver_map->is_shared()) { | 938 if (!receiver_map->is_shared()) { |
| 927 Map::UpdateCodeCache(receiver_map, name, ic); | 939 Map::UpdateCodeCache(receiver_map, name, ic); |
| 928 } | 940 } |
| 929 | 941 |
| 930 return ic; | 942 return ic; |
| 931 } | 943 } |
| 932 | 944 |
| 933 | 945 |
| 934 Handle<Code> StubCache::ComputeLoadElementPolymorphic( | 946 Handle<Code> StubCache::ComputeLoadElementPolymorphic( |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 Handle<FunctionTemplateInfo>( | 2105 Handle<FunctionTemplateInfo>( |
| 2094 FunctionTemplateInfo::cast(signature->receiver())); | 2106 FunctionTemplateInfo::cast(signature->receiver())); |
| 2095 } | 2107 } |
| 2096 } | 2108 } |
| 2097 | 2109 |
| 2098 is_simple_api_call_ = true; | 2110 is_simple_api_call_ = true; |
| 2099 } | 2111 } |
| 2100 | 2112 |
| 2101 | 2113 |
| 2102 } } // namespace v8::internal | 2114 } } // namespace v8::internal |
| OLD | NEW |