OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 Activate(code); | 132 Activate(code); |
133 } else { | 133 } else { |
134 CHECK(IsPregenerated() == code->is_pregenerated()); | 134 CHECK(IsPregenerated() == code->is_pregenerated()); |
135 } | 135 } |
136 | 136 |
137 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); | 137 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); |
138 return Handle<Code>(code, isolate); | 138 return Handle<Code>(code, isolate); |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 MaybeObject* CodeStub::TryGetCode() { | |
143 Code* code; | |
144 if (!FindCodeInCache(&code)) { | |
145 // Generate the new code. | |
146 MacroAssembler masm(Isolate::Current(), NULL, 256); | |
147 GenerateCode(&masm); | |
148 Heap* heap = masm.isolate()->heap(); | |
149 | |
150 // Create the code object. | |
151 CodeDesc desc; | |
152 masm.GetCode(&desc); | |
153 | |
154 // Try to copy the generated code into a heap object. | |
155 Code::Flags flags = Code::ComputeFlags( | |
156 static_cast<Code::Kind>(GetCodeKind()), | |
157 GetICState()); | |
158 Object* new_object; | |
159 { MaybeObject* maybe_new_object = | |
160 heap->CreateCode(desc, flags, masm.CodeObject()); | |
161 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | |
162 } | |
163 code = Code::cast(new_object); | |
164 RecordCodeGeneration(code, &masm); | |
165 FinishCode(code); | |
166 | |
167 // Try to update the code cache but do not fail if unable. | |
168 MaybeObject* maybe_new_object = | |
169 heap->code_stubs()->AtNumberPut(GetKey(), code); | |
170 if (maybe_new_object->ToObject(&new_object)) { | |
171 heap->public_set_code_stubs(NumberDictionary::cast(new_object)); | |
172 } else if (MustBeInStubCache()) { | |
173 return maybe_new_object; | |
174 } | |
175 | |
176 Activate(code); | |
177 } | |
178 | |
179 return code; | |
180 } | |
181 | |
182 | |
183 const char* CodeStub::MajorName(CodeStub::Major major_key, | 142 const char* CodeStub::MajorName(CodeStub::Major major_key, |
184 bool allow_unknown_keys) { | 143 bool allow_unknown_keys) { |
185 switch (major_key) { | 144 switch (major_key) { |
186 #define DEF_CASE(name) case name: return #name "Stub"; | 145 #define DEF_CASE(name) case name: return #name "Stub"; |
187 CODE_STUB_LIST(DEF_CASE) | 146 CODE_STUB_LIST(DEF_CASE) |
188 #undef DEF_CASE | 147 #undef DEF_CASE |
189 default: | 148 default: |
190 if (!allow_unknown_keys) { | 149 if (!allow_unknown_keys) { |
191 UNREACHABLE(); | 150 UNREACHABLE(); |
192 } | 151 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_); | 393 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_); |
435 } else { | 394 } else { |
436 UNREACHABLE(); | 395 UNREACHABLE(); |
437 } | 396 } |
438 } | 397 } |
439 masm->bind(&fail); | 398 masm->bind(&fail); |
440 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_); | 399 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_); |
441 } | 400 } |
442 | 401 |
443 } } // namespace v8::internal | 402 } } // namespace v8::internal |
OLD | NEW |