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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 *secondary = *primary; | 86 *secondary = *primary; |
87 } | 87 } |
88 | 88 |
89 // Update primary cache. | 89 // Update primary cache. |
90 primary->key = name; | 90 primary->key = name; |
91 primary->value = code; | 91 primary->value = code; |
92 return code; | 92 return code; |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 Object* StubCache::ComputeLoadNonexistent(String* name, JSObject* receiver) { | |
97 // The code stub for loading nonexistent properties can be reused | |
98 // for all names, so we use the empty_string as the name in the map | |
99 // code cache. | |
100 Code::Flags flags = | |
101 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); | |
102 Object* code = receiver->map()->FindInCodeCache(Heap::empty_string(), flags); | |
103 if (code->IsUndefined()) { | |
104 LoadStubCompiler compiler; | |
105 code = compiler.CompileLoadNonexistent(receiver); | |
106 if (code->IsFailure()) return code; | |
107 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, | |
108 Code::cast(code), | |
109 Heap::empty_string())); | |
110 Object* result = receiver->map()->UpdateCodeCache(Heap::empty_string(), | |
111 Code::cast(code)); | |
112 if (result->IsFailure()) return result; | |
113 } | |
114 return Set(name, receiver->map(), Code::cast(code)); | |
115 } | |
116 | |
117 | |
118 Object* StubCache::ComputeLoadField(String* name, | 96 Object* StubCache::ComputeLoadField(String* name, |
119 JSObject* receiver, | 97 JSObject* receiver, |
120 JSObject* holder, | 98 JSObject* holder, |
121 int field_index) { | 99 int field_index) { |
122 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 100 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
123 Object* code = receiver->map()->FindInCodeCache(name, flags); | 101 Object* code = receiver->map()->FindInCodeCache(name, flags); |
124 if (code->IsUndefined()) { | 102 if (code->IsUndefined()) { |
125 LoadStubCompiler compiler; | 103 LoadStubCompiler compiler; |
126 code = compiler.CompileLoadField(receiver, holder, field_index, name); | 104 code = compiler.CompileLoadField(receiver, holder, field_index, name); |
127 if (code->IsFailure()) return code; | 105 if (code->IsFailure()) return code; |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 if (!result->IsFailure()) { | 1126 if (!result->IsFailure()) { |
1149 Code* code = Code::cast(result); | 1127 Code* code = Code::cast(result); |
1150 USE(code); | 1128 USE(code); |
1151 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); | 1129 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); |
1152 } | 1130 } |
1153 return result; | 1131 return result; |
1154 } | 1132 } |
1155 | 1133 |
1156 | 1134 |
1157 } } // namespace v8::internal | 1135 } } // namespace v8::internal |
OLD | NEW |