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

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

Issue 6321012: Version 3.0.9... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 11 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 | « src/stub-cache.h ('k') | src/third_party/strongtalk/LICENSE » ('j') | 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "api.h" 30 #include "api.h"
31 #include "arguments.h" 31 #include "arguments.h"
32 #include "gdb-jit.h"
32 #include "ic-inl.h" 33 #include "ic-inl.h"
33 #include "stub-cache.h" 34 #include "stub-cache.h"
34 #include "vm-state-inl.h" 35 #include "vm-state-inl.h"
35 36
36 namespace v8 { 37 namespace v8 {
37 namespace internal { 38 namespace internal {
38 39
39 // ----------------------------------------------------------------------- 40 // -----------------------------------------------------------------------
40 // StubCache implementation. 41 // StubCache implementation.
41 42
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Code::Flags flags = 116 Code::Flags flags =
116 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT); 117 Code::ComputeMonomorphicFlags(Code::LOAD_IC, NONEXISTENT);
117 Object* code = receiver->map()->FindInCodeCache(cache_name, flags); 118 Object* code = receiver->map()->FindInCodeCache(cache_name, flags);
118 if (code->IsUndefined()) { 119 if (code->IsUndefined()) {
119 LoadStubCompiler compiler; 120 LoadStubCompiler compiler;
120 { MaybeObject* maybe_code = 121 { MaybeObject* maybe_code =
121 compiler.CompileLoadNonexistent(cache_name, receiver, last); 122 compiler.CompileLoadNonexistent(cache_name, receiver, last);
122 if (!maybe_code->ToObject(&code)) return maybe_code; 123 if (!maybe_code->ToObject(&code)) return maybe_code;
123 } 124 }
124 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name)); 125 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), cache_name));
126 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, cache_name, Code::cast(code)));
125 Object* result; 127 Object* result;
126 { MaybeObject* maybe_result = 128 { MaybeObject* maybe_result =
127 receiver->UpdateMapCodeCache(cache_name, Code::cast(code)); 129 receiver->UpdateMapCodeCache(cache_name, Code::cast(code));
128 if (!maybe_result->ToObject(&result)) return maybe_result; 130 if (!maybe_result->ToObject(&result)) return maybe_result;
129 } 131 }
130 } 132 }
131 return code; 133 return code;
132 } 134 }
133 135
134 136
135 MaybeObject* StubCache::ComputeLoadField(String* name, 137 MaybeObject* StubCache::ComputeLoadField(String* name,
136 JSObject* receiver, 138 JSObject* receiver,
137 JSObject* holder, 139 JSObject* holder,
138 int field_index) { 140 int field_index) {
139 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 141 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
140 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); 142 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD);
141 Object* code = receiver->map()->FindInCodeCache(name, flags); 143 Object* code = receiver->map()->FindInCodeCache(name, flags);
142 if (code->IsUndefined()) { 144 if (code->IsUndefined()) {
143 LoadStubCompiler compiler; 145 LoadStubCompiler compiler;
144 { MaybeObject* maybe_code = 146 { MaybeObject* maybe_code =
145 compiler.CompileLoadField(receiver, holder, field_index, name); 147 compiler.CompileLoadField(receiver, holder, field_index, name);
146 if (!maybe_code->ToObject(&code)) return maybe_code; 148 if (!maybe_code->ToObject(&code)) return maybe_code;
147 } 149 }
148 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 150 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
151 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
149 Object* result; 152 Object* result;
150 { MaybeObject* maybe_result = 153 { MaybeObject* maybe_result =
151 receiver->UpdateMapCodeCache(name, Code::cast(code)); 154 receiver->UpdateMapCodeCache(name, Code::cast(code));
152 if (!maybe_result->ToObject(&result)) return maybe_result; 155 if (!maybe_result->ToObject(&result)) return maybe_result;
153 } 156 }
154 } 157 }
155 return code; 158 return code;
156 } 159 }
157 160
158 161
159 MaybeObject* StubCache::ComputeLoadCallback(String* name, 162 MaybeObject* StubCache::ComputeLoadCallback(String* name,
160 JSObject* receiver, 163 JSObject* receiver,
161 JSObject* holder, 164 JSObject* holder,
162 AccessorInfo* callback) { 165 AccessorInfo* callback) {
163 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); 166 ASSERT(v8::ToCData<Address>(callback->getter()) != 0);
164 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 167 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
165 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); 168 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS);
166 Object* code = receiver->map()->FindInCodeCache(name, flags); 169 Object* code = receiver->map()->FindInCodeCache(name, flags);
167 if (code->IsUndefined()) { 170 if (code->IsUndefined()) {
168 LoadStubCompiler compiler; 171 LoadStubCompiler compiler;
169 { MaybeObject* maybe_code = 172 { MaybeObject* maybe_code =
170 compiler.CompileLoadCallback(name, receiver, holder, callback); 173 compiler.CompileLoadCallback(name, receiver, holder, callback);
171 if (!maybe_code->ToObject(&code)) return maybe_code; 174 if (!maybe_code->ToObject(&code)) return maybe_code;
172 } 175 }
173 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 176 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
177 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
174 Object* result; 178 Object* result;
175 { MaybeObject* maybe_result = 179 { MaybeObject* maybe_result =
176 receiver->UpdateMapCodeCache(name, Code::cast(code)); 180 receiver->UpdateMapCodeCache(name, Code::cast(code));
177 if (!maybe_result->ToObject(&result)) return maybe_result; 181 if (!maybe_result->ToObject(&result)) return maybe_result;
178 } 182 }
179 } 183 }
180 return code; 184 return code;
181 } 185 }
182 186
183 187
184 MaybeObject* StubCache::ComputeLoadConstant(String* name, 188 MaybeObject* StubCache::ComputeLoadConstant(String* name,
185 JSObject* receiver, 189 JSObject* receiver,
186 JSObject* holder, 190 JSObject* holder,
187 Object* value) { 191 Object* value) {
188 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 192 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
189 Code::Flags flags = 193 Code::Flags flags =
190 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); 194 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION);
191 Object* code = receiver->map()->FindInCodeCache(name, flags); 195 Object* code = receiver->map()->FindInCodeCache(name, flags);
192 if (code->IsUndefined()) { 196 if (code->IsUndefined()) {
193 LoadStubCompiler compiler; 197 LoadStubCompiler compiler;
194 { MaybeObject* maybe_code = 198 { MaybeObject* maybe_code =
195 compiler.CompileLoadConstant(receiver, holder, value, name); 199 compiler.CompileLoadConstant(receiver, holder, value, name);
196 if (!maybe_code->ToObject(&code)) return maybe_code; 200 if (!maybe_code->ToObject(&code)) return maybe_code;
197 } 201 }
198 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 202 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
203 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
199 Object* result; 204 Object* result;
200 { MaybeObject* maybe_result = 205 { MaybeObject* maybe_result =
201 receiver->UpdateMapCodeCache(name, Code::cast(code)); 206 receiver->UpdateMapCodeCache(name, Code::cast(code));
202 if (!maybe_result->ToObject(&result)) return maybe_result; 207 if (!maybe_result->ToObject(&result)) return maybe_result;
203 } 208 }
204 } 209 }
205 return code; 210 return code;
206 } 211 }
207 212
208 213
209 MaybeObject* StubCache::ComputeLoadInterceptor(String* name, 214 MaybeObject* StubCache::ComputeLoadInterceptor(String* name,
210 JSObject* receiver, 215 JSObject* receiver,
211 JSObject* holder) { 216 JSObject* holder) {
212 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 217 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
213 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR); 218 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, INTERCEPTOR);
214 Object* code = receiver->map()->FindInCodeCache(name, flags); 219 Object* code = receiver->map()->FindInCodeCache(name, flags);
215 if (code->IsUndefined()) { 220 if (code->IsUndefined()) {
216 LoadStubCompiler compiler; 221 LoadStubCompiler compiler;
217 { MaybeObject* maybe_code = 222 { MaybeObject* maybe_code =
218 compiler.CompileLoadInterceptor(receiver, holder, name); 223 compiler.CompileLoadInterceptor(receiver, holder, name);
219 if (!maybe_code->ToObject(&code)) return maybe_code; 224 if (!maybe_code->ToObject(&code)) return maybe_code;
220 } 225 }
221 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 226 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
227 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
222 Object* result; 228 Object* result;
223 { MaybeObject* maybe_result = 229 { MaybeObject* maybe_result =
224 receiver->UpdateMapCodeCache(name, Code::cast(code)); 230 receiver->UpdateMapCodeCache(name, Code::cast(code));
225 if (!maybe_result->ToObject(&result)) return maybe_result; 231 if (!maybe_result->ToObject(&result)) return maybe_result;
226 } 232 }
227 } 233 }
228 return code; 234 return code;
229 } 235 }
230 236
231 237
(...skipping 13 matching lines...) Expand all
245 if (code->IsUndefined()) { 251 if (code->IsUndefined()) {
246 LoadStubCompiler compiler; 252 LoadStubCompiler compiler;
247 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver, 253 { MaybeObject* maybe_code = compiler.CompileLoadGlobal(receiver,
248 holder, 254 holder,
249 cell, 255 cell,
250 name, 256 name,
251 is_dont_delete); 257 is_dont_delete);
252 if (!maybe_code->ToObject(&code)) return maybe_code; 258 if (!maybe_code->ToObject(&code)) return maybe_code;
253 } 259 }
254 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); 260 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name));
261 GDBJIT(AddCode(GDBJITInterface::LOAD_IC, name, Code::cast(code)));
255 Object* result; 262 Object* result;
256 { MaybeObject* maybe_result = 263 { MaybeObject* maybe_result =
257 receiver->UpdateMapCodeCache(name, Code::cast(code)); 264 receiver->UpdateMapCodeCache(name, Code::cast(code));
258 if (!maybe_result->ToObject(&result)) return maybe_result; 265 if (!maybe_result->ToObject(&result)) return maybe_result;
259 } 266 }
260 } 267 }
261 return code; 268 return code;
262 } 269 }
263 270
264 271
265 MaybeObject* StubCache::ComputeKeyedLoadField(String* name, 272 MaybeObject* StubCache::ComputeKeyedLoadField(String* name,
266 JSObject* receiver, 273 JSObject* receiver,
267 JSObject* holder, 274 JSObject* holder,
268 int field_index) { 275 int field_index) {
269 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 276 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
270 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD); 277 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, FIELD);
271 Object* code = receiver->map()->FindInCodeCache(name, flags); 278 Object* code = receiver->map()->FindInCodeCache(name, flags);
272 if (code->IsUndefined()) { 279 if (code->IsUndefined()) {
273 KeyedLoadStubCompiler compiler; 280 KeyedLoadStubCompiler compiler;
274 { MaybeObject* maybe_code = 281 { MaybeObject* maybe_code =
275 compiler.CompileLoadField(name, receiver, holder, field_index); 282 compiler.CompileLoadField(name, receiver, holder, field_index);
276 if (!maybe_code->ToObject(&code)) return maybe_code; 283 if (!maybe_code->ToObject(&code)) return maybe_code;
277 } 284 }
278 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 285 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
286 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
279 Object* result; 287 Object* result;
280 { MaybeObject* maybe_result = 288 { MaybeObject* maybe_result =
281 receiver->UpdateMapCodeCache(name, Code::cast(code)); 289 receiver->UpdateMapCodeCache(name, Code::cast(code));
282 if (!maybe_result->ToObject(&result)) return maybe_result; 290 if (!maybe_result->ToObject(&result)) return maybe_result;
283 } 291 }
284 } 292 }
285 return code; 293 return code;
286 } 294 }
287 295
288 296
289 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name, 297 MaybeObject* StubCache::ComputeKeyedLoadConstant(String* name,
290 JSObject* receiver, 298 JSObject* receiver,
291 JSObject* holder, 299 JSObject* holder,
292 Object* value) { 300 Object* value) {
293 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 301 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
294 Code::Flags flags = 302 Code::Flags flags =
295 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION); 303 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CONSTANT_FUNCTION);
296 Object* code = receiver->map()->FindInCodeCache(name, flags); 304 Object* code = receiver->map()->FindInCodeCache(name, flags);
297 if (code->IsUndefined()) { 305 if (code->IsUndefined()) {
298 KeyedLoadStubCompiler compiler; 306 KeyedLoadStubCompiler compiler;
299 { MaybeObject* maybe_code = 307 { MaybeObject* maybe_code =
300 compiler.CompileLoadConstant(name, receiver, holder, value); 308 compiler.CompileLoadConstant(name, receiver, holder, value);
301 if (!maybe_code->ToObject(&code)) return maybe_code; 309 if (!maybe_code->ToObject(&code)) return maybe_code;
302 } 310 }
303 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 311 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
312 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
304 Object* result; 313 Object* result;
305 { MaybeObject* maybe_result = 314 { MaybeObject* maybe_result =
306 receiver->UpdateMapCodeCache(name, Code::cast(code)); 315 receiver->UpdateMapCodeCache(name, Code::cast(code));
307 if (!maybe_result->ToObject(&result)) return maybe_result; 316 if (!maybe_result->ToObject(&result)) return maybe_result;
308 } 317 }
309 } 318 }
310 return code; 319 return code;
311 } 320 }
312 321
313 322
314 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name, 323 MaybeObject* StubCache::ComputeKeyedLoadInterceptor(String* name,
315 JSObject* receiver, 324 JSObject* receiver,
316 JSObject* holder) { 325 JSObject* holder) {
317 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 326 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
318 Code::Flags flags = 327 Code::Flags flags =
319 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR); 328 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, INTERCEPTOR);
320 Object* code = receiver->map()->FindInCodeCache(name, flags); 329 Object* code = receiver->map()->FindInCodeCache(name, flags);
321 if (code->IsUndefined()) { 330 if (code->IsUndefined()) {
322 KeyedLoadStubCompiler compiler; 331 KeyedLoadStubCompiler compiler;
323 { MaybeObject* maybe_code = 332 { MaybeObject* maybe_code =
324 compiler.CompileLoadInterceptor(receiver, holder, name); 333 compiler.CompileLoadInterceptor(receiver, holder, name);
325 if (!maybe_code->ToObject(&code)) return maybe_code; 334 if (!maybe_code->ToObject(&code)) return maybe_code;
326 } 335 }
327 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 336 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
337 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
328 Object* result; 338 Object* result;
329 { MaybeObject* maybe_result = 339 { MaybeObject* maybe_result =
330 receiver->UpdateMapCodeCache(name, Code::cast(code)); 340 receiver->UpdateMapCodeCache(name, Code::cast(code));
331 if (!maybe_result->ToObject(&result)) return maybe_result; 341 if (!maybe_result->ToObject(&result)) return maybe_result;
332 } 342 }
333 } 343 }
334 return code; 344 return code;
335 } 345 }
336 346
337 347
338 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name, 348 MaybeObject* StubCache::ComputeKeyedLoadCallback(String* name,
339 JSObject* receiver, 349 JSObject* receiver,
340 JSObject* holder, 350 JSObject* holder,
341 AccessorInfo* callback) { 351 AccessorInfo* callback) {
342 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP); 352 ASSERT(IC::GetCodeCacheForObject(receiver, holder) == OWN_MAP);
343 Code::Flags flags = 353 Code::Flags flags =
344 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 354 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
345 Object* code = receiver->map()->FindInCodeCache(name, flags); 355 Object* code = receiver->map()->FindInCodeCache(name, flags);
346 if (code->IsUndefined()) { 356 if (code->IsUndefined()) {
347 KeyedLoadStubCompiler compiler; 357 KeyedLoadStubCompiler compiler;
348 { MaybeObject* maybe_code = 358 { MaybeObject* maybe_code =
349 compiler.CompileLoadCallback(name, receiver, holder, callback); 359 compiler.CompileLoadCallback(name, receiver, holder, callback);
350 if (!maybe_code->ToObject(&code)) return maybe_code; 360 if (!maybe_code->ToObject(&code)) return maybe_code;
351 } 361 }
352 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 362 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
363 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
353 Object* result; 364 Object* result;
354 { MaybeObject* maybe_result = 365 { MaybeObject* maybe_result =
355 receiver->UpdateMapCodeCache(name, Code::cast(code)); 366 receiver->UpdateMapCodeCache(name, Code::cast(code));
356 if (!maybe_result->ToObject(&result)) return maybe_result; 367 if (!maybe_result->ToObject(&result)) return maybe_result;
357 } 368 }
358 } 369 }
359 return code; 370 return code;
360 } 371 }
361 372
362 373
363 374
364 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name, 375 MaybeObject* StubCache::ComputeKeyedLoadArrayLength(String* name,
365 JSArray* receiver) { 376 JSArray* receiver) {
366 Code::Flags flags = 377 Code::Flags flags =
367 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 378 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
368 ASSERT(receiver->IsJSObject()); 379 ASSERT(receiver->IsJSObject());
369 Object* code = receiver->map()->FindInCodeCache(name, flags); 380 Object* code = receiver->map()->FindInCodeCache(name, flags);
370 if (code->IsUndefined()) { 381 if (code->IsUndefined()) {
371 KeyedLoadStubCompiler compiler; 382 KeyedLoadStubCompiler compiler;
372 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name); 383 { MaybeObject* maybe_code = compiler.CompileLoadArrayLength(name);
373 if (!maybe_code->ToObject(&code)) return maybe_code; 384 if (!maybe_code->ToObject(&code)) return maybe_code;
374 } 385 }
375 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 386 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
387 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
376 Object* result; 388 Object* result;
377 { MaybeObject* maybe_result = 389 { MaybeObject* maybe_result =
378 receiver->UpdateMapCodeCache(name, Code::cast(code)); 390 receiver->UpdateMapCodeCache(name, Code::cast(code));
379 if (!maybe_result->ToObject(&result)) return maybe_result; 391 if (!maybe_result->ToObject(&result)) return maybe_result;
380 } 392 }
381 } 393 }
382 return code; 394 return code;
383 } 395 }
384 396
385 397
386 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name, 398 MaybeObject* StubCache::ComputeKeyedLoadStringLength(String* name,
387 String* receiver) { 399 String* receiver) {
388 Code::Flags flags = 400 Code::Flags flags =
389 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 401 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
390 Map* map = receiver->map(); 402 Map* map = receiver->map();
391 Object* code = map->FindInCodeCache(name, flags); 403 Object* code = map->FindInCodeCache(name, flags);
392 if (code->IsUndefined()) { 404 if (code->IsUndefined()) {
393 KeyedLoadStubCompiler compiler; 405 KeyedLoadStubCompiler compiler;
394 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name); 406 { MaybeObject* maybe_code = compiler.CompileLoadStringLength(name);
395 if (!maybe_code->ToObject(&code)) return maybe_code; 407 if (!maybe_code->ToObject(&code)) return maybe_code;
396 } 408 }
397 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 409 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
410 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
398 Object* result; 411 Object* result;
399 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code)); 412 { MaybeObject* maybe_result = map->UpdateCodeCache(name, Code::cast(code));
400 if (!maybe_result->ToObject(&result)) return maybe_result; 413 if (!maybe_result->ToObject(&result)) return maybe_result;
401 } 414 }
402 } 415 }
403 return code; 416 return code;
404 } 417 }
405 418
406 419
407 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype( 420 MaybeObject* StubCache::ComputeKeyedLoadFunctionPrototype(
408 String* name, 421 String* name,
409 JSFunction* receiver) { 422 JSFunction* receiver) {
410 Code::Flags flags = 423 Code::Flags flags =
411 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS); 424 Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, CALLBACKS);
412 Object* code = receiver->map()->FindInCodeCache(name, flags); 425 Object* code = receiver->map()->FindInCodeCache(name, flags);
413 if (code->IsUndefined()) { 426 if (code->IsUndefined()) {
414 KeyedLoadStubCompiler compiler; 427 KeyedLoadStubCompiler compiler;
415 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name); 428 { MaybeObject* maybe_code = compiler.CompileLoadFunctionPrototype(name);
416 if (!maybe_code->ToObject(&code)) return maybe_code; 429 if (!maybe_code->ToObject(&code)) return maybe_code;
417 } 430 }
418 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name)); 431 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, Code::cast(code), name));
432 GDBJIT(AddCode(GDBJITInterface::KEYED_LOAD_IC, name, Code::cast(code)));
419 Object* result; 433 Object* result;
420 { MaybeObject* maybe_result = 434 { MaybeObject* maybe_result =
421 receiver->UpdateMapCodeCache(name, Code::cast(code)); 435 receiver->UpdateMapCodeCache(name, Code::cast(code));
422 if (!maybe_result->ToObject(&result)) return maybe_result; 436 if (!maybe_result->ToObject(&result)) return maybe_result;
423 } 437 }
424 } 438 }
425 return code; 439 return code;
426 } 440 }
427 441
428 442
(...skipping 25 matching lines...) Expand all
454 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; 468 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;
455 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); 469 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type);
456 Object* code = receiver->map()->FindInCodeCache(name, flags); 470 Object* code = receiver->map()->FindInCodeCache(name, flags);
457 if (code->IsUndefined()) { 471 if (code->IsUndefined()) {
458 StoreStubCompiler compiler; 472 StoreStubCompiler compiler;
459 { MaybeObject* maybe_code = 473 { MaybeObject* maybe_code =
460 compiler.CompileStoreField(receiver, field_index, transition, name); 474 compiler.CompileStoreField(receiver, field_index, transition, name);
461 if (!maybe_code->ToObject(&code)) return maybe_code; 475 if (!maybe_code->ToObject(&code)) return maybe_code;
462 } 476 }
463 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 477 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
478 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
464 Object* result; 479 Object* result;
465 { MaybeObject* maybe_result = 480 { MaybeObject* maybe_result =
466 receiver->UpdateMapCodeCache(name, Code::cast(code)); 481 receiver->UpdateMapCodeCache(name, Code::cast(code));
467 if (!maybe_result->ToObject(&result)) return maybe_result; 482 if (!maybe_result->ToObject(&result)) return maybe_result;
468 } 483 }
469 } 484 }
470 return code; 485 return code;
471 } 486 }
472 487
473 488
(...skipping 28 matching lines...) Expand all
502 JSGlobalPropertyCell* cell) { 517 JSGlobalPropertyCell* cell) {
503 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL); 518 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL);
504 Object* code = receiver->map()->FindInCodeCache(name, flags); 519 Object* code = receiver->map()->FindInCodeCache(name, flags);
505 if (code->IsUndefined()) { 520 if (code->IsUndefined()) {
506 StoreStubCompiler compiler; 521 StoreStubCompiler compiler;
507 { MaybeObject* maybe_code = 522 { MaybeObject* maybe_code =
508 compiler.CompileStoreGlobal(receiver, cell, name); 523 compiler.CompileStoreGlobal(receiver, cell, name);
509 if (!maybe_code->ToObject(&code)) return maybe_code; 524 if (!maybe_code->ToObject(&code)) return maybe_code;
510 } 525 }
511 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 526 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
527 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
512 Object* result; 528 Object* result;
513 { MaybeObject* maybe_result = 529 { MaybeObject* maybe_result =
514 receiver->UpdateMapCodeCache(name, Code::cast(code)); 530 receiver->UpdateMapCodeCache(name, Code::cast(code));
515 if (!maybe_result->ToObject(&result)) return maybe_result; 531 if (!maybe_result->ToObject(&result)) return maybe_result;
516 } 532 }
517 } 533 }
518 return code; 534 return code;
519 } 535 }
520 536
521 537
522 MaybeObject* StubCache::ComputeStoreCallback(String* name, 538 MaybeObject* StubCache::ComputeStoreCallback(String* name,
523 JSObject* receiver, 539 JSObject* receiver,
524 AccessorInfo* callback) { 540 AccessorInfo* callback) {
525 ASSERT(v8::ToCData<Address>(callback->setter()) != 0); 541 ASSERT(v8::ToCData<Address>(callback->setter()) != 0);
526 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS); 542 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, CALLBACKS);
527 Object* code = receiver->map()->FindInCodeCache(name, flags); 543 Object* code = receiver->map()->FindInCodeCache(name, flags);
528 if (code->IsUndefined()) { 544 if (code->IsUndefined()) {
529 StoreStubCompiler compiler; 545 StoreStubCompiler compiler;
530 { MaybeObject* maybe_code = 546 { MaybeObject* maybe_code =
531 compiler.CompileStoreCallback(receiver, callback, name); 547 compiler.CompileStoreCallback(receiver, callback, name);
532 if (!maybe_code->ToObject(&code)) return maybe_code; 548 if (!maybe_code->ToObject(&code)) return maybe_code;
533 } 549 }
534 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 550 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
551 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
535 Object* result; 552 Object* result;
536 { MaybeObject* maybe_result = 553 { MaybeObject* maybe_result =
537 receiver->UpdateMapCodeCache(name, Code::cast(code)); 554 receiver->UpdateMapCodeCache(name, Code::cast(code));
538 if (!maybe_result->ToObject(&result)) return maybe_result; 555 if (!maybe_result->ToObject(&result)) return maybe_result;
539 } 556 }
540 } 557 }
541 return code; 558 return code;
542 } 559 }
543 560
544 561
545 MaybeObject* StubCache::ComputeStoreInterceptor(String* name, 562 MaybeObject* StubCache::ComputeStoreInterceptor(String* name,
546 JSObject* receiver) { 563 JSObject* receiver) {
547 Code::Flags flags = 564 Code::Flags flags =
548 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR); 565 Code::ComputeMonomorphicFlags(Code::STORE_IC, INTERCEPTOR);
549 Object* code = receiver->map()->FindInCodeCache(name, flags); 566 Object* code = receiver->map()->FindInCodeCache(name, flags);
550 if (code->IsUndefined()) { 567 if (code->IsUndefined()) {
551 StoreStubCompiler compiler; 568 StoreStubCompiler compiler;
552 { MaybeObject* maybe_code = 569 { MaybeObject* maybe_code =
553 compiler.CompileStoreInterceptor(receiver, name); 570 compiler.CompileStoreInterceptor(receiver, name);
554 if (!maybe_code->ToObject(&code)) return maybe_code; 571 if (!maybe_code->ToObject(&code)) return maybe_code;
555 } 572 }
556 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name)); 573 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, Code::cast(code), name));
574 GDBJIT(AddCode(GDBJITInterface::STORE_IC, name, Code::cast(code)));
557 Object* result; 575 Object* result;
558 { MaybeObject* maybe_result = 576 { MaybeObject* maybe_result =
559 receiver->UpdateMapCodeCache(name, Code::cast(code)); 577 receiver->UpdateMapCodeCache(name, Code::cast(code));
560 if (!maybe_result->ToObject(&result)) return maybe_result; 578 if (!maybe_result->ToObject(&result)) return maybe_result;
561 } 579 }
562 } 580 }
563 return code; 581 return code;
564 } 582 }
565 583
566 584
567 MaybeObject* StubCache::ComputeKeyedStoreField(String* name, 585 MaybeObject* StubCache::ComputeKeyedStoreField(String* name,
568 JSObject* receiver, 586 JSObject* receiver,
569 int field_index, 587 int field_index,
570 Map* transition) { 588 Map* transition) {
571 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION; 589 PropertyType type = (transition == NULL) ? FIELD : MAP_TRANSITION;
572 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); 590 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type);
573 Object* code = receiver->map()->FindInCodeCache(name, flags); 591 Object* code = receiver->map()->FindInCodeCache(name, flags);
574 if (code->IsUndefined()) { 592 if (code->IsUndefined()) {
575 KeyedStoreStubCompiler compiler; 593 KeyedStoreStubCompiler compiler;
576 { MaybeObject* maybe_code = 594 { MaybeObject* maybe_code =
577 compiler.CompileStoreField(receiver, field_index, transition, name); 595 compiler.CompileStoreField(receiver, field_index, transition, name);
578 if (!maybe_code->ToObject(&code)) return maybe_code; 596 if (!maybe_code->ToObject(&code)) return maybe_code;
579 } 597 }
580 PROFILE(CodeCreateEvent( 598 PROFILE(CodeCreateEvent(
581 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name)); 599 Logger::KEYED_STORE_IC_TAG, Code::cast(code), name));
600 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, name, Code::cast(code)));
582 Object* result; 601 Object* result;
583 { MaybeObject* maybe_result = 602 { MaybeObject* maybe_result =
584 receiver->UpdateMapCodeCache(name, Code::cast(code)); 603 receiver->UpdateMapCodeCache(name, Code::cast(code));
585 if (!maybe_result->ToObject(&result)) return maybe_result; 604 if (!maybe_result->ToObject(&result)) return maybe_result;
586 } 605 }
587 } 606 }
588 return code; 607 return code;
589 } 608 }
590 609
591 #define CALL_LOGGER_TAG(kind, type) \ 610 #define CALL_LOGGER_TAG(kind, type) \
592 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type) 611 (kind == Code::CALL_IC ? Logger::type : Logger::KEYED_##type)
593 612
594 MaybeObject* StubCache::ComputeCallConstant(int argc, 613 MaybeObject* StubCache::ComputeCallConstant(int argc,
595 InLoopFlag in_loop, 614 InLoopFlag in_loop,
596 Code::Kind kind, 615 Code::Kind kind,
616 Code::ExtraICState extra_ic_state,
597 String* name, 617 String* name,
598 Object* object, 618 Object* object,
599 JSObject* holder, 619 JSObject* holder,
600 JSFunction* function) { 620 JSFunction* function) {
601 // Compute the check type and the map. 621 // Compute the check type and the map.
602 InlineCacheHolderFlag cache_holder = 622 InlineCacheHolderFlag cache_holder =
603 IC::GetCodeCacheForObject(object, holder); 623 IC::GetCodeCacheForObject(object, holder);
604 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); 624 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder);
605 625
606 // Compute check type based on receiver/holder. 626 // Compute check type based on receiver/holder.
607 CheckType check = RECEIVER_MAP_CHECK; 627 CheckType check = RECEIVER_MAP_CHECK;
608 if (object->IsString()) { 628 if (object->IsString()) {
609 check = STRING_CHECK; 629 check = STRING_CHECK;
610 } else if (object->IsNumber()) { 630 } else if (object->IsNumber()) {
611 check = NUMBER_CHECK; 631 check = NUMBER_CHECK;
612 } else if (object->IsBoolean()) { 632 } else if (object->IsBoolean()) {
613 check = BOOLEAN_CHECK; 633 check = BOOLEAN_CHECK;
614 } 634 }
615 635
616 Code::Flags flags = 636 Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
617 Code::ComputeMonomorphicFlags(kind, 637 CONSTANT_FUNCTION,
618 CONSTANT_FUNCTION, 638 extra_ic_state,
619 cache_holder, 639 cache_holder,
620 in_loop, 640 in_loop,
621 argc); 641 argc);
622 Object* code = map_holder->map()->FindInCodeCache(name, flags); 642 Object* code = map_holder->map()->FindInCodeCache(name, flags);
623 if (code->IsUndefined()) { 643 if (code->IsUndefined()) {
624 // If the function hasn't been compiled yet, we cannot do it now 644 // If the function hasn't been compiled yet, we cannot do it now
625 // because it may cause GC. To avoid this issue, we return an 645 // because it may cause GC. To avoid this issue, we return an
626 // internal error which will make sure we do not update any 646 // internal error which will make sure we do not update any
627 // caches. 647 // caches.
628 if (!function->is_compiled()) return Failure::InternalError(); 648 if (!function->is_compiled()) return Failure::InternalError();
629 // Compile the stub - only create stubs for fully compiled functions. 649 // Compile the stub - only create stubs for fully compiled functions.
630 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); 650 CallStubCompiler compiler(
651 argc, in_loop, kind, extra_ic_state, cache_holder);
631 { MaybeObject* maybe_code = 652 { MaybeObject* maybe_code =
632 compiler.CompileCallConstant(object, holder, function, name, check); 653 compiler.CompileCallConstant(object, holder, function, name, check);
633 if (!maybe_code->ToObject(&code)) return maybe_code; 654 if (!maybe_code->ToObject(&code)) return maybe_code;
634 } 655 }
635 Code::cast(code)->set_check_type(check); 656 Code::cast(code)->set_check_type(check);
636 ASSERT_EQ(flags, Code::cast(code)->flags()); 657 ASSERT_EQ(flags, Code::cast(code)->flags());
637 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 658 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
638 Code::cast(code), name)); 659 Code::cast(code), name));
660 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
639 Object* result; 661 Object* result;
640 { MaybeObject* maybe_result = 662 { MaybeObject* maybe_result =
641 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 663 map_holder->UpdateMapCodeCache(name, Code::cast(code));
642 if (!maybe_result->ToObject(&result)) return maybe_result; 664 if (!maybe_result->ToObject(&result)) return maybe_result;
643 } 665 }
644 } 666 }
645 return code; 667 return code;
646 } 668 }
647 669
648 670
(...skipping 11 matching lines...) Expand all
660 682
661 // TODO(1233596): We cannot do receiver map check for non-JS objects 683 // TODO(1233596): We cannot do receiver map check for non-JS objects
662 // because they may be represented as immediates without a 684 // because they may be represented as immediates without a
663 // map. Instead, we check against the map in the holder. 685 // map. Instead, we check against the map in the holder.
664 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { 686 if (object->IsNumber() || object->IsBoolean() || object->IsString()) {
665 object = holder; 687 object = holder;
666 } 688 }
667 689
668 Code::Flags flags = Code::ComputeMonomorphicFlags(kind, 690 Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
669 FIELD, 691 FIELD,
692 Code::kNoExtraICState,
670 cache_holder, 693 cache_holder,
671 in_loop, 694 in_loop,
672 argc); 695 argc);
673 Object* code = map_holder->map()->FindInCodeCache(name, flags); 696 Object* code = map_holder->map()->FindInCodeCache(name, flags);
674 if (code->IsUndefined()) { 697 if (code->IsUndefined()) {
675 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); 698 CallStubCompiler compiler(
699 argc, in_loop, kind, Code::kNoExtraICState, cache_holder);
676 { MaybeObject* maybe_code = 700 { MaybeObject* maybe_code =
677 compiler.CompileCallField(JSObject::cast(object), 701 compiler.CompileCallField(JSObject::cast(object),
678 holder, 702 holder,
679 index, 703 index,
680 name); 704 name);
681 if (!maybe_code->ToObject(&code)) return maybe_code; 705 if (!maybe_code->ToObject(&code)) return maybe_code;
682 } 706 }
683 ASSERT_EQ(flags, Code::cast(code)->flags()); 707 ASSERT_EQ(flags, Code::cast(code)->flags());
684 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 708 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
685 Code::cast(code), name)); 709 Code::cast(code), name));
710 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
686 Object* result; 711 Object* result;
687 { MaybeObject* maybe_result = 712 { MaybeObject* maybe_result =
688 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 713 map_holder->UpdateMapCodeCache(name, Code::cast(code));
689 if (!maybe_result->ToObject(&result)) return maybe_result; 714 if (!maybe_result->ToObject(&result)) return maybe_result;
690 } 715 }
691 } 716 }
692 return code; 717 return code;
693 } 718 }
694 719
695 720
696 MaybeObject* StubCache::ComputeCallInterceptor(int argc, 721 MaybeObject* StubCache::ComputeCallInterceptor(int argc,
697 Code::Kind kind, 722 Code::Kind kind,
698 String* name, 723 String* name,
699 Object* object, 724 Object* object,
700 JSObject* holder) { 725 JSObject* holder) {
701 // Compute the check type and the map. 726 // Compute the check type and the map.
702 InlineCacheHolderFlag cache_holder = 727 InlineCacheHolderFlag cache_holder =
703 IC::GetCodeCacheForObject(object, holder); 728 IC::GetCodeCacheForObject(object, holder);
704 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder); 729 JSObject* map_holder = IC::GetCodeCacheHolder(object, cache_holder);
705 730
706 // TODO(1233596): We cannot do receiver map check for non-JS objects 731 // TODO(1233596): We cannot do receiver map check for non-JS objects
707 // because they may be represented as immediates without a 732 // because they may be represented as immediates without a
708 // map. Instead, we check against the map in the holder. 733 // map. Instead, we check against the map in the holder.
709 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { 734 if (object->IsNumber() || object->IsBoolean() || object->IsString()) {
710 object = holder; 735 object = holder;
711 } 736 }
712 737
713 Code::Flags flags = 738 Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
714 Code::ComputeMonomorphicFlags(kind, 739 INTERCEPTOR,
715 INTERCEPTOR, 740 Code::kNoExtraICState,
716 cache_holder, 741 cache_holder,
717 NOT_IN_LOOP, 742 NOT_IN_LOOP,
718 argc); 743 argc);
719 Object* code = map_holder->map()->FindInCodeCache(name, flags); 744 Object* code = map_holder->map()->FindInCodeCache(name, flags);
720 if (code->IsUndefined()) { 745 if (code->IsUndefined()) {
721 CallStubCompiler compiler(argc, NOT_IN_LOOP, kind, cache_holder); 746 CallStubCompiler compiler(
747 argc, NOT_IN_LOOP, kind, Code::kNoExtraICState, cache_holder);
722 { MaybeObject* maybe_code = 748 { MaybeObject* maybe_code =
723 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name); 749 compiler.CompileCallInterceptor(JSObject::cast(object), holder, name);
724 if (!maybe_code->ToObject(&code)) return maybe_code; 750 if (!maybe_code->ToObject(&code)) return maybe_code;
725 } 751 }
726 ASSERT_EQ(flags, Code::cast(code)->flags()); 752 ASSERT_EQ(flags, Code::cast(code)->flags());
727 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 753 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
728 Code::cast(code), name)); 754 Code::cast(code), name));
755 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
729 Object* result; 756 Object* result;
730 { MaybeObject* maybe_result = 757 { MaybeObject* maybe_result =
731 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 758 map_holder->UpdateMapCodeCache(name, Code::cast(code));
732 if (!maybe_result->ToObject(&result)) return maybe_result; 759 if (!maybe_result->ToObject(&result)) return maybe_result;
733 } 760 }
734 } 761 }
735 return code; 762 return code;
736 } 763 }
737 764
738 765
(...skipping 14 matching lines...) Expand all
753 InLoopFlag in_loop, 780 InLoopFlag in_loop,
754 Code::Kind kind, 781 Code::Kind kind,
755 String* name, 782 String* name,
756 JSObject* receiver, 783 JSObject* receiver,
757 GlobalObject* holder, 784 GlobalObject* holder,
758 JSGlobalPropertyCell* cell, 785 JSGlobalPropertyCell* cell,
759 JSFunction* function) { 786 JSFunction* function) {
760 InlineCacheHolderFlag cache_holder = 787 InlineCacheHolderFlag cache_holder =
761 IC::GetCodeCacheForObject(receiver, holder); 788 IC::GetCodeCacheForObject(receiver, holder);
762 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder); 789 JSObject* map_holder = IC::GetCodeCacheHolder(receiver, cache_holder);
763 Code::Flags flags = 790 Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
764 Code::ComputeMonomorphicFlags(kind, 791 NORMAL,
765 NORMAL, 792 Code::kNoExtraICState,
766 cache_holder, 793 cache_holder,
767 in_loop, 794 in_loop,
768 argc); 795 argc);
769 Object* code = map_holder->map()->FindInCodeCache(name, flags); 796 Object* code = map_holder->map()->FindInCodeCache(name, flags);
770 if (code->IsUndefined()) { 797 if (code->IsUndefined()) {
771 // If the function hasn't been compiled yet, we cannot do it now 798 // If the function hasn't been compiled yet, we cannot do it now
772 // because it may cause GC. To avoid this issue, we return an 799 // because it may cause GC. To avoid this issue, we return an
773 // internal error which will make sure we do not update any 800 // internal error which will make sure we do not update any
774 // caches. 801 // caches.
775 if (!function->is_compiled()) return Failure::InternalError(); 802 if (!function->is_compiled()) return Failure::InternalError();
776 CallStubCompiler compiler(argc, in_loop, kind, cache_holder); 803 CallStubCompiler compiler(
804 argc, in_loop, kind, Code::kNoExtraICState, cache_holder);
777 { MaybeObject* maybe_code = 805 { MaybeObject* maybe_code =
778 compiler.CompileCallGlobal(receiver, holder, cell, function, name); 806 compiler.CompileCallGlobal(receiver, holder, cell, function, name);
779 if (!maybe_code->ToObject(&code)) return maybe_code; 807 if (!maybe_code->ToObject(&code)) return maybe_code;
780 } 808 }
781 ASSERT_EQ(flags, Code::cast(code)->flags()); 809 ASSERT_EQ(flags, Code::cast(code)->flags());
782 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), 810 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG),
783 Code::cast(code), name)); 811 Code::cast(code), name));
812 GDBJIT(AddCode(GDBJITInterface::CALL_IC, name, Code::cast(code)));
784 Object* result; 813 Object* result;
785 { MaybeObject* maybe_result = 814 { MaybeObject* maybe_result =
786 map_holder->UpdateMapCodeCache(name, Code::cast(code)); 815 map_holder->UpdateMapCodeCache(name, Code::cast(code));
787 if (!maybe_result->ToObject(&result)) return maybe_result; 816 if (!maybe_result->ToObject(&result)) return maybe_result;
788 } 817 }
789 } 818 }
790 return code; 819 return code;
791 } 820 }
792 821
793 822
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 CHECK(GetProbeValue(Code::cast(code)->flags()) == code); 861 CHECK(GetProbeValue(Code::cast(code)->flags()) == code);
833 } 862 }
834 } 863 }
835 return maybe_code; 864 return maybe_code;
836 } 865 }
837 866
838 867
839 Code* StubCache::FindCallInitialize(int argc, 868 Code* StubCache::FindCallInitialize(int argc,
840 InLoopFlag in_loop, 869 InLoopFlag in_loop,
841 Code::Kind kind) { 870 Code::Kind kind) {
842 Code::Flags flags = 871 Code::Flags flags = Code::ComputeFlags(kind,
843 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); 872 in_loop,
873 UNINITIALIZED,
874 Code::kNoExtraICState,
875 NORMAL,
876 argc);
844 Object* result = ProbeCache(flags)->ToObjectUnchecked(); 877 Object* result = ProbeCache(flags)->ToObjectUnchecked();
845 ASSERT(!result->IsUndefined()); 878 ASSERT(!result->IsUndefined());
846 // This might be called during the marking phase of the collector 879 // This might be called during the marking phase of the collector
847 // hence the unchecked cast. 880 // hence the unchecked cast.
848 return reinterpret_cast<Code*>(result); 881 return reinterpret_cast<Code*>(result);
849 } 882 }
850 883
851 884
852 MaybeObject* StubCache::ComputeCallInitialize(int argc, 885 MaybeObject* StubCache::ComputeCallInitialize(int argc,
853 InLoopFlag in_loop, 886 InLoopFlag in_loop,
854 Code::Kind kind) { 887 Code::Kind kind) {
855 Code::Flags flags = 888 Code::Flags flags = Code::ComputeFlags(kind,
856 Code::ComputeFlags(kind, in_loop, UNINITIALIZED, NORMAL, argc); 889 in_loop,
890 UNINITIALIZED,
891 Code::kNoExtraICState,
892 NORMAL,
893 argc);
857 Object* probe; 894 Object* probe;
858 { MaybeObject* maybe_probe = ProbeCache(flags); 895 { MaybeObject* maybe_probe = ProbeCache(flags);
859 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 896 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
860 } 897 }
861 if (!probe->IsUndefined()) return probe; 898 if (!probe->IsUndefined()) return probe;
862 StubCompiler compiler; 899 StubCompiler compiler;
863 return FillCache(compiler.CompileCallInitialize(flags)); 900 return FillCache(compiler.CompileCallInitialize(flags));
864 } 901 }
865 902
866 903
(...skipping 21 matching lines...) Expand all
888 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP); 925 ComputeKeyedCallInitialize(argc, NOT_IN_LOOP);
889 } 926 }
890 CALL_HEAP_FUNCTION( 927 CALL_HEAP_FUNCTION(
891 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code); 928 ComputeCallInitialize(argc, in_loop, Code::KEYED_CALL_IC), Code);
892 } 929 }
893 930
894 931
895 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc, 932 MaybeObject* StubCache::ComputeCallPreMonomorphic(int argc,
896 InLoopFlag in_loop, 933 InLoopFlag in_loop,
897 Code::Kind kind) { 934 Code::Kind kind) {
898 Code::Flags flags = 935 Code::Flags flags = Code::ComputeFlags(kind,
899 Code::ComputeFlags(kind, in_loop, PREMONOMORPHIC, NORMAL, argc); 936 in_loop,
937 PREMONOMORPHIC,
938 Code::kNoExtraICState,
939 NORMAL,
940 argc);
900 Object* probe; 941 Object* probe;
901 { MaybeObject* maybe_probe = ProbeCache(flags); 942 { MaybeObject* maybe_probe = ProbeCache(flags);
902 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 943 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
903 } 944 }
904 if (!probe->IsUndefined()) return probe; 945 if (!probe->IsUndefined()) return probe;
905 StubCompiler compiler; 946 StubCompiler compiler;
906 return FillCache(compiler.CompileCallPreMonomorphic(flags)); 947 return FillCache(compiler.CompileCallPreMonomorphic(flags));
907 } 948 }
908 949
909 950
910 MaybeObject* StubCache::ComputeCallNormal(int argc, 951 MaybeObject* StubCache::ComputeCallNormal(int argc,
911 InLoopFlag in_loop, 952 InLoopFlag in_loop,
912 Code::Kind kind) { 953 Code::Kind kind) {
913 Code::Flags flags = 954 Code::Flags flags = Code::ComputeFlags(kind,
914 Code::ComputeFlags(kind, in_loop, MONOMORPHIC, NORMAL, argc); 955 in_loop,
956 MONOMORPHIC,
957 Code::kNoExtraICState,
958 NORMAL,
959 argc);
915 Object* probe; 960 Object* probe;
916 { MaybeObject* maybe_probe = ProbeCache(flags); 961 { MaybeObject* maybe_probe = ProbeCache(flags);
917 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 962 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
918 } 963 }
919 if (!probe->IsUndefined()) return probe; 964 if (!probe->IsUndefined()) return probe;
920 StubCompiler compiler; 965 StubCompiler compiler;
921 return FillCache(compiler.CompileCallNormal(flags)); 966 return FillCache(compiler.CompileCallNormal(flags));
922 } 967 }
923 968
924 969
925 MaybeObject* StubCache::ComputeCallMegamorphic(int argc, 970 MaybeObject* StubCache::ComputeCallMegamorphic(int argc,
926 InLoopFlag in_loop, 971 InLoopFlag in_loop,
927 Code::Kind kind) { 972 Code::Kind kind) {
928 Code::Flags flags = 973 Code::Flags flags = Code::ComputeFlags(kind,
929 Code::ComputeFlags(kind, in_loop, MEGAMORPHIC, NORMAL, argc); 974 in_loop,
975 MEGAMORPHIC,
976 Code::kNoExtraICState,
977 NORMAL,
978 argc);
930 Object* probe; 979 Object* probe;
931 { MaybeObject* maybe_probe = ProbeCache(flags); 980 { MaybeObject* maybe_probe = ProbeCache(flags);
932 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 981 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
933 } 982 }
934 if (!probe->IsUndefined()) return probe; 983 if (!probe->IsUndefined()) return probe;
935 StubCompiler compiler; 984 StubCompiler compiler;
936 return FillCache(compiler.CompileCallMegamorphic(flags)); 985 return FillCache(compiler.CompileCallMegamorphic(flags));
937 } 986 }
938 987
939 988
940 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) { 989 MaybeObject* StubCache::ComputeCallMiss(int argc, Code::Kind kind) {
941 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs 990 // MONOMORPHIC_PROTOTYPE_FAILURE state is used to make sure that miss stubs
942 // and monomorphic stubs are not mixed up together in the stub cache. 991 // and monomorphic stubs are not mixed up together in the stub cache.
943 Code::Flags flags = Code::ComputeFlags( 992 Code::Flags flags = Code::ComputeFlags(kind,
944 kind, NOT_IN_LOOP, MONOMORPHIC_PROTOTYPE_FAILURE, NORMAL, argc); 993 NOT_IN_LOOP,
994 MONOMORPHIC_PROTOTYPE_FAILURE,
995 Code::kNoExtraICState,
996 NORMAL,
997 argc,
998 OWN_MAP);
945 Object* probe; 999 Object* probe;
946 { MaybeObject* maybe_probe = ProbeCache(flags); 1000 { MaybeObject* maybe_probe = ProbeCache(flags);
947 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1001 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
948 } 1002 }
949 if (!probe->IsUndefined()) return probe; 1003 if (!probe->IsUndefined()) return probe;
950 StubCompiler compiler; 1004 StubCompiler compiler;
951 return FillCache(compiler.CompileCallMiss(flags)); 1005 return FillCache(compiler.CompileCallMiss(flags));
952 } 1006 }
953 1007
954 1008
955 #ifdef ENABLE_DEBUGGER_SUPPORT 1009 #ifdef ENABLE_DEBUGGER_SUPPORT
956 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) { 1010 MaybeObject* StubCache::ComputeCallDebugBreak(int argc, Code::Kind kind) {
957 Code::Flags flags = 1011 Code::Flags flags = Code::ComputeFlags(kind,
958 Code::ComputeFlags(kind, NOT_IN_LOOP, DEBUG_BREAK, NORMAL, argc); 1012 NOT_IN_LOOP,
1013 DEBUG_BREAK,
1014 Code::kNoExtraICState,
1015 NORMAL,
1016 argc);
959 Object* probe; 1017 Object* probe;
960 { MaybeObject* maybe_probe = ProbeCache(flags); 1018 { MaybeObject* maybe_probe = ProbeCache(flags);
961 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1019 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
962 } 1020 }
963 if (!probe->IsUndefined()) return probe; 1021 if (!probe->IsUndefined()) return probe;
964 StubCompiler compiler; 1022 StubCompiler compiler;
965 return FillCache(compiler.CompileCallDebugBreak(flags)); 1023 return FillCache(compiler.CompileCallDebugBreak(flags));
966 } 1024 }
967 1025
968 1026
969 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc, 1027 MaybeObject* StubCache::ComputeCallDebugPrepareStepIn(int argc,
970 Code::Kind kind) { 1028 Code::Kind kind) {
971 Code::Flags flags = 1029 Code::Flags flags = Code::ComputeFlags(kind,
972 Code::ComputeFlags(kind, 1030 NOT_IN_LOOP,
973 NOT_IN_LOOP, 1031 DEBUG_PREPARE_STEP_IN,
974 DEBUG_PREPARE_STEP_IN, 1032 Code::kNoExtraICState,
975 NORMAL, 1033 NORMAL,
976 argc); 1034 argc);
977 Object* probe; 1035 Object* probe;
978 { MaybeObject* maybe_probe = ProbeCache(flags); 1036 { MaybeObject* maybe_probe = ProbeCache(flags);
979 if (!maybe_probe->ToObject(&probe)) return maybe_probe; 1037 if (!maybe_probe->ToObject(&probe)) return maybe_probe;
980 } 1038 }
981 if (!probe->IsUndefined()) return probe; 1039 if (!probe->IsUndefined()) return probe;
982 StubCompiler compiler; 1040 StubCompiler compiler;
983 return FillCache(compiler.CompileCallDebugPrepareStepIn(flags)); 1041 return FillCache(compiler.CompileCallDebugPrepareStepIn(flags));
984 } 1042 }
985 #endif 1043 #endif
986 1044
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 Object* result; 1308 Object* result;
1251 { MaybeObject* maybe_result = 1309 { MaybeObject* maybe_result =
1252 GetCodeWithFlags(flags, "CompileCallInitialize"); 1310 GetCodeWithFlags(flags, "CompileCallInitialize");
1253 if (!maybe_result->ToObject(&result)) return maybe_result; 1311 if (!maybe_result->ToObject(&result)) return maybe_result;
1254 } 1312 }
1255 Counters::call_initialize_stubs.Increment(); 1313 Counters::call_initialize_stubs.Increment();
1256 Code* code = Code::cast(result); 1314 Code* code = Code::cast(result);
1257 USE(code); 1315 USE(code);
1258 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG), 1316 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_INITIALIZE_TAG),
1259 code, code->arguments_count())); 1317 code, code->arguments_count()));
1318 GDBJIT(AddCode(GDBJITInterface::CALL_INITIALIZE, Code::cast(code)));
1260 return result; 1319 return result;
1261 } 1320 }
1262 1321
1263 1322
1264 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { 1323 MaybeObject* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) {
1265 HandleScope scope; 1324 HandleScope scope;
1266 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1325 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1267 // The code of the PreMonomorphic stub is the same as the code 1326 // The code of the PreMonomorphic stub is the same as the code
1268 // of the Initialized stub. They just differ on the code object flags. 1327 // of the Initialized stub. They just differ on the code object flags.
1269 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1328 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1270 if (kind == Code::CALL_IC) { 1329 if (kind == Code::CALL_IC) {
1271 CallIC::GenerateInitialize(masm(), argc); 1330 CallIC::GenerateInitialize(masm(), argc);
1272 } else { 1331 } else {
1273 KeyedCallIC::GenerateInitialize(masm(), argc); 1332 KeyedCallIC::GenerateInitialize(masm(), argc);
1274 } 1333 }
1275 Object* result; 1334 Object* result;
1276 { MaybeObject* maybe_result = 1335 { MaybeObject* maybe_result =
1277 GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); 1336 GetCodeWithFlags(flags, "CompileCallPreMonomorphic");
1278 if (!maybe_result->ToObject(&result)) return maybe_result; 1337 if (!maybe_result->ToObject(&result)) return maybe_result;
1279 } 1338 }
1280 Counters::call_premonomorphic_stubs.Increment(); 1339 Counters::call_premonomorphic_stubs.Increment();
1281 Code* code = Code::cast(result); 1340 Code* code = Code::cast(result);
1282 USE(code); 1341 USE(code);
1283 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG), 1342 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG),
1284 code, code->arguments_count())); 1343 code, code->arguments_count()));
1344 GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code)));
1285 return result; 1345 return result;
1286 } 1346 }
1287 1347
1288 1348
1289 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) { 1349 MaybeObject* StubCompiler::CompileCallNormal(Code::Flags flags) {
1290 HandleScope scope; 1350 HandleScope scope;
1291 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1351 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1292 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1352 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1293 if (kind == Code::CALL_IC) { 1353 if (kind == Code::CALL_IC) {
1294 CallIC::GenerateNormal(masm(), argc); 1354 CallIC::GenerateNormal(masm(), argc);
1295 } else { 1355 } else {
1296 KeyedCallIC::GenerateNormal(masm(), argc); 1356 KeyedCallIC::GenerateNormal(masm(), argc);
1297 } 1357 }
1298 Object* result; 1358 Object* result;
1299 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal"); 1359 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallNormal");
1300 if (!maybe_result->ToObject(&result)) return maybe_result; 1360 if (!maybe_result->ToObject(&result)) return maybe_result;
1301 } 1361 }
1302 Counters::call_normal_stubs.Increment(); 1362 Counters::call_normal_stubs.Increment();
1303 Code* code = Code::cast(result); 1363 Code* code = Code::cast(result);
1304 USE(code); 1364 USE(code);
1305 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG), 1365 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG),
1306 code, code->arguments_count())); 1366 code, code->arguments_count()));
1367 GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code)));
1307 return result; 1368 return result;
1308 } 1369 }
1309 1370
1310 1371
1311 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { 1372 MaybeObject* StubCompiler::CompileCallMegamorphic(Code::Flags flags) {
1312 HandleScope scope; 1373 HandleScope scope;
1313 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1374 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1314 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1375 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1315 if (kind == Code::CALL_IC) { 1376 if (kind == Code::CALL_IC) {
1316 CallIC::GenerateMegamorphic(masm(), argc); 1377 CallIC::GenerateMegamorphic(masm(), argc);
1317 } else { 1378 } else {
1318 KeyedCallIC::GenerateMegamorphic(masm(), argc); 1379 KeyedCallIC::GenerateMegamorphic(masm(), argc);
1319 } 1380 }
1320 1381
1321 Object* result; 1382 Object* result;
1322 { MaybeObject* maybe_result = 1383 { MaybeObject* maybe_result =
1323 GetCodeWithFlags(flags, "CompileCallMegamorphic"); 1384 GetCodeWithFlags(flags, "CompileCallMegamorphic");
1324 if (!maybe_result->ToObject(&result)) return maybe_result; 1385 if (!maybe_result->ToObject(&result)) return maybe_result;
1325 } 1386 }
1326 Counters::call_megamorphic_stubs.Increment(); 1387 Counters::call_megamorphic_stubs.Increment();
1327 Code* code = Code::cast(result); 1388 Code* code = Code::cast(result);
1328 USE(code); 1389 USE(code);
1329 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG), 1390 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MEGAMORPHIC_TAG),
1330 code, code->arguments_count())); 1391 code, code->arguments_count()));
1392 GDBJIT(AddCode(GDBJITInterface::CALL_MEGAMORPHIC, Code::cast(code)));
1331 return result; 1393 return result;
1332 } 1394 }
1333 1395
1334 1396
1335 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) { 1397 MaybeObject* StubCompiler::CompileCallMiss(Code::Flags flags) {
1336 HandleScope scope; 1398 HandleScope scope;
1337 int argc = Code::ExtractArgumentsCountFromFlags(flags); 1399 int argc = Code::ExtractArgumentsCountFromFlags(flags);
1338 Code::Kind kind = Code::ExtractKindFromFlags(flags); 1400 Code::Kind kind = Code::ExtractKindFromFlags(flags);
1339 if (kind == Code::CALL_IC) { 1401 if (kind == Code::CALL_IC) {
1340 CallIC::GenerateMiss(masm(), argc); 1402 CallIC::GenerateMiss(masm(), argc);
1341 } else { 1403 } else {
1342 KeyedCallIC::GenerateMiss(masm(), argc); 1404 KeyedCallIC::GenerateMiss(masm(), argc);
1343 } 1405 }
1344 Object* result; 1406 Object* result;
1345 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss"); 1407 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "CompileCallMiss");
1346 if (!maybe_result->ToObject(&result)) return maybe_result; 1408 if (!maybe_result->ToObject(&result)) return maybe_result;
1347 } 1409 }
1348 Counters::call_megamorphic_stubs.Increment(); 1410 Counters::call_megamorphic_stubs.Increment();
1349 Code* code = Code::cast(result); 1411 Code* code = Code::cast(result);
1350 USE(code); 1412 USE(code);
1351 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG), 1413 PROFILE(CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG),
1352 code, code->arguments_count())); 1414 code, code->arguments_count()));
1415 GDBJIT(AddCode(GDBJITInterface::CALL_MISS, Code::cast(code)));
1353 return result; 1416 return result;
1354 } 1417 }
1355 1418
1356 1419
1357 #ifdef ENABLE_DEBUGGER_SUPPORT 1420 #ifdef ENABLE_DEBUGGER_SUPPORT
1358 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { 1421 MaybeObject* StubCompiler::CompileCallDebugBreak(Code::Flags flags) {
1359 HandleScope scope; 1422 HandleScope scope;
1360 Debug::GenerateCallICDebugBreak(masm()); 1423 Debug::GenerateCallICDebugBreak(masm());
1361 Object* result; 1424 Object* result;
1362 { MaybeObject* maybe_result = 1425 { MaybeObject* maybe_result =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 1505
1443 1506
1444 1507
1445 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) { 1508 MaybeObject* LoadStubCompiler::GetCode(PropertyType type, String* name) {
1446 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type); 1509 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, type);
1447 MaybeObject* result = GetCodeWithFlags(flags, name); 1510 MaybeObject* result = GetCodeWithFlags(flags, name);
1448 if (!result->IsFailure()) { 1511 if (!result->IsFailure()) {
1449 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG, 1512 PROFILE(CodeCreateEvent(Logger::LOAD_IC_TAG,
1450 Code::cast(result->ToObjectUnchecked()), 1513 Code::cast(result->ToObjectUnchecked()),
1451 name)); 1514 name));
1515 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1516 name,
1517 Code::cast(result->ToObjectUnchecked())));
1452 } 1518 }
1453 return result; 1519 return result;
1454 } 1520 }
1455 1521
1456 1522
1457 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { 1523 MaybeObject* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) {
1458 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type); 1524 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, type);
1459 MaybeObject* result = GetCodeWithFlags(flags, name); 1525 MaybeObject* result = GetCodeWithFlags(flags, name);
1460 if (!result->IsFailure()) { 1526 if (!result->IsFailure()) {
1461 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG, 1527 PROFILE(CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG,
1462 Code::cast(result->ToObjectUnchecked()), 1528 Code::cast(result->ToObjectUnchecked()),
1463 name)); 1529 name));
1530 GDBJIT(AddCode(GDBJITInterface::LOAD_IC,
1531 name,
1532 Code::cast(result->ToObjectUnchecked())));
1464 } 1533 }
1465 return result; 1534 return result;
1466 } 1535 }
1467 1536
1468 1537
1469 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) { 1538 MaybeObject* StoreStubCompiler::GetCode(PropertyType type, String* name) {
1470 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type); 1539 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, type);
1471 MaybeObject* result = GetCodeWithFlags(flags, name); 1540 MaybeObject* result = GetCodeWithFlags(flags, name);
1472 if (!result->IsFailure()) { 1541 if (!result->IsFailure()) {
1473 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG, 1542 PROFILE(CodeCreateEvent(Logger::STORE_IC_TAG,
1474 Code::cast(result->ToObjectUnchecked()), 1543 Code::cast(result->ToObjectUnchecked()),
1475 name)); 1544 name));
1545 GDBJIT(AddCode(GDBJITInterface::STORE_IC,
1546 name,
1547 Code::cast(result->ToObjectUnchecked())));
1476 } 1548 }
1477 return result; 1549 return result;
1478 } 1550 }
1479 1551
1480 1552
1481 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { 1553 MaybeObject* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) {
1482 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); 1554 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type);
1483 MaybeObject* result = GetCodeWithFlags(flags, name); 1555 MaybeObject* result = GetCodeWithFlags(flags, name);
1484 if (!result->IsFailure()) { 1556 if (!result->IsFailure()) {
1485 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, 1557 PROFILE(CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
1486 Code::cast(result->ToObjectUnchecked()), 1558 Code::cast(result->ToObjectUnchecked()),
1487 name)); 1559 name));
1560 GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC,
1561 name,
1562 Code::cast(result->ToObjectUnchecked())));
1488 } 1563 }
1489 return result; 1564 return result;
1490 } 1565 }
1491 1566
1492 1567
1493 CallStubCompiler::CallStubCompiler(int argc, 1568 CallStubCompiler::CallStubCompiler(int argc,
1494 InLoopFlag in_loop, 1569 InLoopFlag in_loop,
1495 Code::Kind kind, 1570 Code::Kind kind,
1571 Code::ExtraICState extra_ic_state,
1496 InlineCacheHolderFlag cache_holder) 1572 InlineCacheHolderFlag cache_holder)
1497 : arguments_(argc) 1573 : arguments_(argc),
1498 , in_loop_(in_loop) 1574 in_loop_(in_loop),
1499 , kind_(kind) 1575 kind_(kind),
1500 , cache_holder_(cache_holder) { 1576 extra_ic_state_(extra_ic_state),
1577 cache_holder_(cache_holder) {
1501 } 1578 }
1502 1579
1503 1580
1504 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) { 1581 bool CallStubCompiler::HasCustomCallGenerator(BuiltinFunctionId id) {
1505 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; 1582 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true;
1506 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) 1583 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE)
1507 #undef CALL_GENERATOR_CASE 1584 #undef CALL_GENERATOR_CASE
1508 return false; 1585 return false;
1509 } 1586 }
1510 1587
(...skipping 16 matching lines...) Expand all
1527 #undef CALL_GENERATOR_CASE 1604 #undef CALL_GENERATOR_CASE
1528 ASSERT(!HasCustomCallGenerator(id)); 1605 ASSERT(!HasCustomCallGenerator(id));
1529 return Heap::undefined_value(); 1606 return Heap::undefined_value();
1530 } 1607 }
1531 1608
1532 1609
1533 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) { 1610 MaybeObject* CallStubCompiler::GetCode(PropertyType type, String* name) {
1534 int argc = arguments_.immediate(); 1611 int argc = arguments_.immediate();
1535 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_, 1612 Code::Flags flags = Code::ComputeMonomorphicFlags(kind_,
1536 type, 1613 type,
1614 extra_ic_state_,
1537 cache_holder_, 1615 cache_holder_,
1538 in_loop_, 1616 in_loop_,
1539 argc); 1617 argc);
1540 return GetCodeWithFlags(flags, name); 1618 return GetCodeWithFlags(flags, name);
1541 } 1619 }
1542 1620
1543 1621
1544 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) { 1622 MaybeObject* CallStubCompiler::GetCode(JSFunction* function) {
1545 String* function_name = NULL; 1623 String* function_name = NULL;
1546 if (function->shared()->name()->IsString()) { 1624 if (function->shared()->name()->IsString()) {
1547 function_name = String::cast(function->shared()->name()); 1625 function_name = String::cast(function->shared()->name());
1548 } 1626 }
1549 return GetCode(CONSTANT_FUNCTION, function_name); 1627 return GetCode(CONSTANT_FUNCTION, function_name);
1550 } 1628 }
1551 1629
1552 1630
1553 MaybeObject* ConstructStubCompiler::GetCode() { 1631 MaybeObject* ConstructStubCompiler::GetCode() {
1554 Code::Flags flags = Code::ComputeFlags(Code::STUB); 1632 Code::Flags flags = Code::ComputeFlags(Code::STUB);
1555 Object* result; 1633 Object* result;
1556 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub"); 1634 { MaybeObject* maybe_result = GetCodeWithFlags(flags, "ConstructStub");
1557 if (!maybe_result->ToObject(&result)) return maybe_result; 1635 if (!maybe_result->ToObject(&result)) return maybe_result;
1558 } 1636 }
1559 Code* code = Code::cast(result); 1637 Code* code = Code::cast(result);
1560 USE(code); 1638 USE(code);
1561 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub")); 1639 PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, "ConstructStub"));
1640 GDBJIT(AddCode(GDBJITInterface::STUB, "ConstructStub", Code::cast(code)));
1562 return result; 1641 return result;
1563 } 1642 }
1564 1643
1565 1644
1566 CallOptimization::CallOptimization(LookupResult* lookup) { 1645 CallOptimization::CallOptimization(LookupResult* lookup) {
1567 if (!lookup->IsProperty() || !lookup->IsCacheable() || 1646 if (!lookup->IsProperty() || !lookup->IsCacheable() ||
1568 lookup->type() != CONSTANT_FUNCTION) { 1647 lookup->type() != CONSTANT_FUNCTION) {
1569 Initialize(NULL); 1648 Initialize(NULL);
1570 } else { 1649 } else {
1571 // We only optimize constant function calls. 1650 // We only optimize constant function calls.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 expected_receiver_type_ = 1703 expected_receiver_type_ =
1625 FunctionTemplateInfo::cast(signature->receiver()); 1704 FunctionTemplateInfo::cast(signature->receiver());
1626 } 1705 }
1627 } 1706 }
1628 1707
1629 is_simple_api_call_ = true; 1708 is_simple_api_call_ = true;
1630 } 1709 }
1631 1710
1632 1711
1633 } } // namespace v8::internal 1712 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/third_party/strongtalk/LICENSE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698