Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: src/stub-cache.cc

Issue 652039: Consistently return failure if the stub cache cannot deliver a code object... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 JSObject* holder, 98 JSObject* holder,
99 int field_index) { 99 int field_index) {
100 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); 100 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD);
101 Object* code = receiver->map()->FindInCodeCache(name, flags); 101 Object* code = receiver->map()->FindInCodeCache(name, flags);
102 if (code->IsUndefined()) { 102 if (code->IsUndefined()) {
103 LoadStubCompiler compiler; 103 LoadStubCompiler compiler;
104 code = compiler.CompileLoadField(receiver, holder, field_index, name); 104 code = compiler.CompileLoadField(receiver, holder, field_index, name);
105 if (code->IsFailure()) return code; 105 if (code->IsFailure()) return code;
106 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 106 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
107 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 107 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
108 if (result->IsFailure()) return code; 108 if (result->IsFailure()) return result;
109 } 109 }
110 return Set(name, receiver->map(), Code::cast(code)); 110 return Set(name, receiver->map(), Code::cast(code));
111 } 111 }
112 112
113 113
114 Object* StubCache::ComputeLoadCallback(String* name, 114 Object* StubCache::ComputeLoadCallback(String* name,
115 JSObject* receiver, 115 JSObject* receiver,
116 JSObject* holder, 116 JSObject* holder,
117 AccessorInfo* callback) { 117 AccessorInfo* callback) {
118 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); 118 ASSERT(v8::ToCData<Address>(callback->getter()) != 0);
119 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); 119 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS);
120 Object* code = receiver->map()->FindInCodeCache(name, flags); 120 Object* code = receiver->map()->FindInCodeCache(name, flags);
121 if (code->IsUndefined()) { 121 if (code->IsUndefined()) {
122 LoadStubCompiler compiler; 122 LoadStubCompiler compiler;
123 code = compiler.CompileLoadCallback(name, receiver, holder, callback); 123 code = compiler.CompileLoadCallback(name, receiver, holder, callback);
124 if (code->IsFailure()) return code; 124 if (code->IsFailure()) return code;
125 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 125 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
126 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 126 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
127 if (result->IsFailure()) return code; 127 if (result->IsFailure()) return result;
128 } 128 }
129 return Set(name, receiver->map(), Code::cast(code)); 129 return Set(name, receiver->map(), Code::cast(code));
130 } 130 }
131 131
132 132
133 Object* StubCache::ComputeLoadConstant(String* name, 133 Object* StubCache::ComputeLoadConstant(String* name,
134 JSObject* receiver, 134 JSObject* receiver,
135 JSObject* holder, 135 JSObject* holder,
136 Object* value) { 136 Object* value) {
137 Code::Flags flags = 137 Code::Flags flags =
138 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); 138 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION);
139 Object* code = receiver->map()->FindInCodeCache(name, flags); 139 Object* code = receiver->map()->FindInCodeCache(name, flags);
140 if (code->IsUndefined()) { 140 if (code->IsUndefined()) {
141 LoadStubCompiler compiler; 141 LoadStubCompiler compiler;
142 code = compiler.CompileLoadConstant(receiver, holder, value, name); 142 code = compiler.CompileLoadConstant(receiver, holder, value, name);
143 if (code->IsFailure()) return code; 143 if (code->IsFailure()) return code;
144 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 144 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
145 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 145 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
146 if (result->IsFailure()) return code; 146 if (result->IsFailure()) return result;
147 } 147 }
148 return Set(name, receiver->map(), Code::cast(code)); 148 return Set(name, receiver->map(), Code::cast(code));
149 } 149 }
150 150
151 151
152 Object* StubCache::ComputeLoadInterceptor(String* name, 152 Object* StubCache::ComputeLoadInterceptor(String* name,
153 JSObject* receiver, 153 JSObject* receiver,
154 JSObject* holder) { 154 JSObject* holder) {
155 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); 155 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR);
156 Object* code = receiver->map()->FindInCodeCache(name, flags); 156 Object* code = receiver->map()->FindInCodeCache(name, flags);
157 if (code->IsUndefined()) { 157 if (code->IsUndefined()) {
158 LoadStubCompiler compiler; 158 LoadStubCompiler compiler;
159 code = compiler.CompileLoadInterceptor(receiver, holder, name); 159 code = compiler.CompileLoadInterceptor(receiver, holder, name);
160 if (code->IsFailure()) return code; 160 if (code->IsFailure()) return code;
161 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 161 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
162 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 162 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
163 if (result->IsFailure()) return code; 163 if (result->IsFailure()) return result;
164 } 164 }
165 return Set(name, receiver->map(), Code::cast(code)); 165 return Set(name, receiver->map(), Code::cast(code));
166 } 166 }
167 167
168 168
169 Object* StubCache::ComputeLoadNormal(String* name, JSObject* receiver) { 169 Object* StubCache::ComputeLoadNormal(String* name, JSObject* receiver) {
170 Code* code = Builtins::builtin(Builtins::LoadIC_Normal); 170 Code* code = Builtins::builtin(Builtins::LoadIC_Normal);
171 return Set(name, receiver->map(), code); 171 return Set(name, receiver->map(), code);
172 } 172 }
173 173
174 174
175 Object* StubCache::ComputeLoadGlobal(String* name, 175 Object* StubCache::ComputeLoadGlobal(String* name,
176 JSObject* receiver, 176 JSObject* receiver,
177 GlobalObject* holder, 177 GlobalObject* holder,
178 JSGlobalPropertyCell* cell, 178 JSGlobalPropertyCell* cell,
179 bool is_dont_delete) { 179 bool is_dont_delete) {
180 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); 180 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL);
181 Object* code = receiver->map()->FindInCodeCache(name, flags); 181 Object* code = receiver->map()->FindInCodeCache(name, flags);
182 if (code->IsUndefined()) { 182 if (code->IsUndefined()) {
183 LoadStubCompiler compiler; 183 LoadStubCompiler compiler;
184 code = compiler.CompileLoadGlobal(receiver, 184 code = compiler.CompileLoadGlobal(receiver,
185 holder, 185 holder,
186 cell, 186 cell,
187 name, 187 name,
188 is_dont_delete); 188 is_dont_delete);
189 if (code->IsFailure()) return code; 189 if (code->IsFailure()) return code;
190 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 190 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
191 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 191 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
192 if (result->IsFailure()) return code; 192 if (result->IsFailure()) return result;
193 } 193 }
194 return Set(name, receiver->map(), Code::cast(code)); 194 return Set(name, receiver->map(), Code::cast(code));
195 } 195 }
196 196
197 197
198 Object* StubCache::ComputeKeyedLoadField(String* name, 198 Object* StubCache::ComputeKeyedLoadField(String* name,
199 JSObject* receiver, 199 JSObject* receiver,
200 JSObject* holder, 200 JSObject* holder,
201 int field_index) { 201 int field_index) {
202 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); 202 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 GlobalObject* receiver, 344 GlobalObject* receiver,
345 JSGlobalPropertyCell* cell) { 345 JSGlobalPropertyCell* cell) {
346 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); 346 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL);
347 Object* code = receiver->map()->FindInCodeCache(name, flags); 347 Object* code = receiver->map()->FindInCodeCache(name, flags);
348 if (code->IsUndefined()) { 348 if (code->IsUndefined()) {
349 StoreStubCompiler compiler; 349 StoreStubCompiler compiler;
350 code = compiler.CompileStoreGlobal(receiver, cell, name); 350 code = compiler.CompileStoreGlobal(receiver, cell, name);
351 if (code->IsFailure()) return code; 351 if (code->IsFailure()) return code;
352 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 352 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
353 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 353 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
354 if (result->IsFailure()) return code; 354 if (result->IsFailure()) return result;
355 } 355 }
356 return Set(name, receiver->map(), Code::cast(code)); 356 return Set(name, receiver->map(), Code::cast(code));
357 } 357 }
358 358
359 359
360 Object* StubCache::ComputeStoreCallback(String* name, 360 Object* StubCache::ComputeStoreCallback(String* name,
361 JSObject* receiver, 361 JSObject* receiver,
362 AccessorInfo* callback) { 362 AccessorInfo* callback) {
363 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); 363 ASSERT(v8::ToCData<Address>(callback->setter()) != 0);
364 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); 364 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // because it may cause GC. To avoid this issue, we return an 559 // because it may cause GC. To avoid this issue, we return an
560 // internal error which will make sure we do not update any 560 // internal error which will make sure we do not update any
561 // caches. 561 // caches.
562 if (!function->is_compiled()) return Failure::InternalError(); 562 if (!function->is_compiled()) return Failure::InternalError();
563 CallStubCompiler compiler(argc, in_loop); 563 CallStubCompiler compiler(argc, in_loop);
564 code = compiler.CompileCallGlobal(receiver, holder, cell, function, name); 564 code = compiler.CompileCallGlobal(receiver, holder, cell, function, name);
565 if (code->IsFailure()) return code; 565 if (code->IsFailure()) return code;
566 ASSERT_EQ(flags, Code::cast(code)->flags()); 566 ASSERT_EQ(flags, Code::cast(code)->flags());
567 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); 567 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name));
568 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); 568 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
569 if (result->IsFailure()) return code; 569 if (result->IsFailure()) return result;
570 } 570 }
571 return Set(name, receiver->map(), Code::cast(code)); 571 return Set(name, receiver->map(), Code::cast(code));
572 } 572 }
573 573
574 574
575 static Object* GetProbeValue(Code::Flags flags) { 575 static Object* GetProbeValue(Code::Flags flags) {
576 // Use raw_unchecked... so we don't get assert failures during GC. 576 // Use raw_unchecked... so we don't get assert failures during GC.
577 NumberDictionary* dictionary = Heap::raw_unchecked_non_monomorphic_cache(); 577 NumberDictionary* dictionary = Heap::raw_unchecked_non_monomorphic_cache();
578 int entry = dictionary->FindEntry(flags); 578 int entry = dictionary->FindEntry(flags);
579 if (entry != -1) return dictionary->ValueAt(entry); 579 if (entry != -1) return dictionary->ValueAt(entry);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 if (!result->IsFailure()) { 1126 if (!result->IsFailure()) {
1127 Code* code = Code::cast(result); 1127 Code* code = Code::cast(result);
1128 USE(code); 1128 USE(code);
1129 LOG(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); 1129 LOG(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub"));
1130 } 1130 }
1131 return result; 1131 return result;
1132 } 1132 }
1133 1133
1134 1134
1135 } } // namespace v8::internal 1135 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698