OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 new_object); | 116 new_object); |
117 Heap::public_set_code_stubs(*dict); | 117 Heap::public_set_code_stubs(*dict); |
118 } | 118 } |
119 code = *new_object; | 119 code = *new_object; |
120 } | 120 } |
121 | 121 |
122 return Handle<Code>(code); | 122 return Handle<Code>(code); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 Object* CodeStub::TryGetCode() { | 126 MaybeObject* CodeStub::TryGetCode() { |
127 Code* code; | 127 Code* code; |
128 if (!FindCodeInCache(&code)) { | 128 if (!FindCodeInCache(&code)) { |
129 // Generate the new code. | 129 // Generate the new code. |
130 MacroAssembler masm(NULL, 256); | 130 MacroAssembler masm(NULL, 256); |
131 GenerateCode(&masm); | 131 GenerateCode(&masm); |
132 | 132 |
133 // Create the code object. | 133 // Create the code object. |
134 CodeDesc desc; | 134 CodeDesc desc; |
135 masm.GetCode(&desc); | 135 masm.GetCode(&desc); |
136 | 136 |
137 // Try to copy the generated code into a heap object. | 137 // Try to copy the generated code into a heap object. |
138 Code::Flags flags = Code::ComputeFlags( | 138 Code::Flags flags = Code::ComputeFlags( |
139 static_cast<Code::Kind>(GetCodeKind()), | 139 static_cast<Code::Kind>(GetCodeKind()), |
140 InLoop(), | 140 InLoop(), |
141 GetICState()); | 141 GetICState()); |
142 Object* new_object = Heap::CreateCode(desc, flags, masm.CodeObject()); | 142 Object* new_object; |
143 if (new_object->IsFailure()) return new_object; | 143 { MaybeObject* maybe_new_object = |
| 144 Heap::CreateCode(desc, flags, masm.CodeObject()); |
| 145 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| 146 } |
144 code = Code::cast(new_object); | 147 code = Code::cast(new_object); |
145 RecordCodeGeneration(code, &masm); | 148 RecordCodeGeneration(code, &masm); |
146 | 149 |
147 if (has_custom_cache()) { | 150 if (has_custom_cache()) { |
148 SetCustomCache(code); | 151 SetCustomCache(code); |
149 } else { | 152 } else { |
150 // Try to update the code cache but do not fail if unable. | 153 // Try to update the code cache but do not fail if unable. |
151 new_object = Heap::code_stubs()->AtNumberPut(GetKey(), code); | 154 MaybeObject* maybe_new_object = |
152 if (!new_object->IsFailure()) { | 155 Heap::code_stubs()->AtNumberPut(GetKey(), code); |
| 156 if (maybe_new_object->ToObject(&new_object)) { |
153 Heap::public_set_code_stubs(NumberDictionary::cast(new_object)); | 157 Heap::public_set_code_stubs(NumberDictionary::cast(new_object)); |
154 } | 158 } |
155 } | 159 } |
156 } | 160 } |
157 | 161 |
158 return code; | 162 return code; |
159 } | 163 } |
160 | 164 |
161 | 165 |
162 const char* CodeStub::MajorName(CodeStub::Major major_key, | 166 const char* CodeStub::MajorName(CodeStub::Major major_key, |
163 bool allow_unknown_keys) { | 167 bool allow_unknown_keys) { |
164 switch (major_key) { | 168 switch (major_key) { |
165 #define DEF_CASE(name) case name: return #name; | 169 #define DEF_CASE(name) case name: return #name; |
166 CODE_STUB_LIST(DEF_CASE) | 170 CODE_STUB_LIST(DEF_CASE) |
167 #undef DEF_CASE | 171 #undef DEF_CASE |
168 default: | 172 default: |
169 if (!allow_unknown_keys) { | 173 if (!allow_unknown_keys) { |
170 UNREACHABLE(); | 174 UNREACHABLE(); |
171 } | 175 } |
172 return NULL; | 176 return NULL; |
173 } | 177 } |
174 } | 178 } |
175 | 179 |
176 | 180 |
177 } } // namespace v8::internal | 181 } } // namespace v8::internal |
OLD | NEW |