OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 JSGlobalObject* receiver, | 176 JSGlobalObject* receiver, |
177 JSGlobalPropertyCell* cell) { | 177 JSGlobalPropertyCell* cell, |
| 178 bool is_dont_delete) { |
178 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); | 179 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL); |
179 Object* code = receiver->map()->FindInCodeCache(name, flags); | 180 Object* code = receiver->map()->FindInCodeCache(name, flags); |
180 if (code->IsUndefined()) { | 181 if (code->IsUndefined()) { |
181 LoadStubCompiler compiler; | 182 LoadStubCompiler compiler; |
182 code = compiler.CompileLoadGlobal(receiver, cell, name); | 183 code = compiler.CompileLoadGlobal(receiver, cell, name, is_dont_delete); |
183 if (code->IsFailure()) return code; | 184 if (code->IsFailure()) return code; |
184 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); | 185 LOG(CodeCreateEvent(Logger::LOAD_IC_TAG, Code::cast(code), name)); |
185 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); | 186 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
186 if (result->IsFailure()) return code; | 187 if (result->IsFailure()) return code; |
187 } | 188 } |
188 return Set(name, receiver->map(), Code::cast(code)); | 189 return Set(name, receiver->map(), Code::cast(code)); |
189 } | 190 } |
190 | 191 |
191 | 192 |
192 Object* StubCache::ComputeKeyedLoadField(String* name, | 193 Object* StubCache::ComputeKeyedLoadField(String* name, |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 check = StubCompiler::JSARRAY_HAS_FAST_ELEMENTS_CHECK; | 437 check = StubCompiler::JSARRAY_HAS_FAST_ELEMENTS_CHECK; |
437 function = JSFunction::cast(opt); | 438 function = JSFunction::cast(opt); |
438 } | 439 } |
439 } | 440 } |
440 // If the function hasn't been compiled yet, we cannot do it now | 441 // If the function hasn't been compiled yet, we cannot do it now |
441 // because it may cause GC. To avoid this issue, we return an | 442 // because it may cause GC. To avoid this issue, we return an |
442 // internal error which will make sure we do not update any | 443 // internal error which will make sure we do not update any |
443 // caches. | 444 // caches. |
444 if (!function->is_compiled()) return Failure::InternalError(); | 445 if (!function->is_compiled()) return Failure::InternalError(); |
445 // Compile the stub - only create stubs for fully compiled functions. | 446 // Compile the stub - only create stubs for fully compiled functions. |
446 CallStubCompiler compiler(argc); | 447 CallStubCompiler compiler(argc, in_loop); |
447 code = compiler.CompileCallConstant(object, holder, function, check, flags); | 448 code = compiler.CompileCallConstant(object, holder, function, check); |
448 if (code->IsFailure()) return code; | 449 if (code->IsFailure()) return code; |
| 450 ASSERT_EQ(flags, Code::cast(code)->flags()); |
449 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); | 451 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); |
450 Object* result = map->UpdateCodeCache(name, Code::cast(code)); | 452 Object* result = map->UpdateCodeCache(name, Code::cast(code)); |
451 if (result->IsFailure()) return result; | 453 if (result->IsFailure()) return result; |
452 } | 454 } |
453 return Set(name, map, Code::cast(code)); | 455 return Set(name, map, Code::cast(code)); |
454 } | 456 } |
455 | 457 |
456 | 458 |
457 Object* StubCache::ComputeCallField(int argc, | 459 Object* StubCache::ComputeCallField(int argc, |
458 InLoopFlag in_loop, | 460 InLoopFlag in_loop, |
(...skipping 10 matching lines...) Expand all Loading... |
469 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 471 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
470 object = holder; | 472 object = holder; |
471 } | 473 } |
472 | 474 |
473 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, | 475 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, |
474 FIELD, | 476 FIELD, |
475 in_loop, | 477 in_loop, |
476 argc); | 478 argc); |
477 Object* code = map->FindInCodeCache(name, flags); | 479 Object* code = map->FindInCodeCache(name, flags); |
478 if (code->IsUndefined()) { | 480 if (code->IsUndefined()) { |
479 CallStubCompiler compiler(argc); | 481 CallStubCompiler compiler(argc, in_loop); |
480 code = compiler.CompileCallField(object, holder, index, name, flags); | 482 code = compiler.CompileCallField(object, holder, index, name); |
481 if (code->IsFailure()) return code; | 483 if (code->IsFailure()) return code; |
| 484 ASSERT_EQ(flags, Code::cast(code)->flags()); |
482 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); | 485 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); |
483 Object* result = map->UpdateCodeCache(name, Code::cast(code)); | 486 Object* result = map->UpdateCodeCache(name, Code::cast(code)); |
484 if (result->IsFailure()) return result; | 487 if (result->IsFailure()) return result; |
485 } | 488 } |
486 return Set(name, map, Code::cast(code)); | 489 return Set(name, map, Code::cast(code)); |
487 } | 490 } |
488 | 491 |
489 | 492 |
490 Object* StubCache::ComputeCallInterceptor(int argc, | 493 Object* StubCache::ComputeCallInterceptor(int argc, |
491 String* name, | 494 String* name, |
(...skipping 10 matching lines...) Expand all Loading... |
502 object = holder; | 505 object = holder; |
503 } | 506 } |
504 | 507 |
505 Code::Flags flags = | 508 Code::Flags flags = |
506 Code::ComputeMonomorphicFlags(Code::CALL_IC, | 509 Code::ComputeMonomorphicFlags(Code::CALL_IC, |
507 INTERCEPTOR, | 510 INTERCEPTOR, |
508 NOT_IN_LOOP, | 511 NOT_IN_LOOP, |
509 argc); | 512 argc); |
510 Object* code = map->FindInCodeCache(name, flags); | 513 Object* code = map->FindInCodeCache(name, flags); |
511 if (code->IsUndefined()) { | 514 if (code->IsUndefined()) { |
512 CallStubCompiler compiler(argc); | 515 CallStubCompiler compiler(argc, NOT_IN_LOOP); |
513 code = compiler.CompileCallInterceptor(object, holder, name); | 516 code = compiler.CompileCallInterceptor(object, holder, name); |
514 if (code->IsFailure()) return code; | 517 if (code->IsFailure()) return code; |
| 518 ASSERT_EQ(flags, Code::cast(code)->flags()); |
515 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); | 519 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); |
516 Object* result = map->UpdateCodeCache(name, Code::cast(code)); | 520 Object* result = map->UpdateCodeCache(name, Code::cast(code)); |
517 if (result->IsFailure()) return result; | 521 if (result->IsFailure()) return result; |
518 } | 522 } |
519 return Set(name, map, Code::cast(code)); | 523 return Set(name, map, Code::cast(code)); |
520 } | 524 } |
521 | 525 |
522 | 526 |
523 Object* StubCache::ComputeCallNormal(int argc, | 527 Object* StubCache::ComputeCallNormal(int argc, |
524 InLoopFlag in_loop, | 528 InLoopFlag in_loop, |
525 String* name, | 529 String* name, |
526 JSObject* receiver) { | 530 JSObject* receiver) { |
527 Object* code = ComputeCallNormal(argc, in_loop); | 531 Object* code = ComputeCallNormal(argc, in_loop); |
528 if (code->IsFailure()) return code; | 532 if (code->IsFailure()) return code; |
529 return Set(name, receiver->map(), Code::cast(code)); | 533 return Set(name, receiver->map(), Code::cast(code)); |
530 } | 534 } |
531 | 535 |
532 | 536 |
533 Object* StubCache::ComputeCallGlobal(int argc, | 537 Object* StubCache::ComputeCallGlobal(int argc, |
534 InLoopFlag in_loop, | 538 InLoopFlag in_loop, |
535 String* name, | 539 String* name, |
536 JSGlobalObject* receiver, | 540 JSGlobalObject* receiver, |
537 JSGlobalPropertyCell* cell, | 541 JSGlobalPropertyCell* cell, |
538 JSFunction* function) { | 542 JSFunction* function) { |
539 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, NORMAL); | 543 Code::Flags flags = |
| 544 Code::ComputeMonomorphicFlags(Code::CALL_IC, NORMAL, in_loop, argc); |
540 Object* code = receiver->map()->FindInCodeCache(name, flags); | 545 Object* code = receiver->map()->FindInCodeCache(name, flags); |
541 if (code->IsUndefined()) { | 546 if (code->IsUndefined()) { |
542 // If the function hasn't been compiled yet, we cannot do it now | 547 // If the function hasn't been compiled yet, we cannot do it now |
543 // because it may cause GC. To avoid this issue, we return an | 548 // because it may cause GC. To avoid this issue, we return an |
544 // internal error which will make sure we do not update any | 549 // internal error which will make sure we do not update any |
545 // caches. | 550 // caches. |
546 if (!function->is_compiled()) return Failure::InternalError(); | 551 if (!function->is_compiled()) return Failure::InternalError(); |
547 CallStubCompiler compiler(argc); | 552 CallStubCompiler compiler(argc, in_loop); |
548 code = compiler.CompileCallGlobal(receiver, cell, function, name); | 553 code = compiler.CompileCallGlobal(receiver, cell, function, name); |
549 if (code->IsFailure()) return code; | 554 if (code->IsFailure()) return code; |
| 555 ASSERT_EQ(flags, Code::cast(code)->flags()); |
550 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); | 556 LOG(CodeCreateEvent(Logger::CALL_IC_TAG, Code::cast(code), name)); |
551 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); | 557 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
552 if (result->IsFailure()) return code; | 558 if (result->IsFailure()) return code; |
553 } | 559 } |
554 return Set(name, receiver->map(), Code::cast(code)); | 560 return Set(name, receiver->map(), Code::cast(code)); |
555 } | 561 } |
556 | 562 |
557 | 563 |
558 static Object* GetProbeValue(Code::Flags flags) { | 564 static Object* GetProbeValue(Code::Flags flags) { |
559 Dictionary* dictionary = Heap::non_monomorphic_cache(); | 565 Dictionary* dictionary = Heap::non_monomorphic_cache(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 Object* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { | 991 Object* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { |
986 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); | 992 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, type); |
987 return GetCodeWithFlags(flags, name); | 993 return GetCodeWithFlags(flags, name); |
988 } | 994 } |
989 | 995 |
990 | 996 |
991 Object* CallStubCompiler::GetCode(PropertyType type, String* name) { | 997 Object* CallStubCompiler::GetCode(PropertyType type, String* name) { |
992 int argc = arguments_.immediate(); | 998 int argc = arguments_.immediate(); |
993 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, | 999 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, |
994 type, | 1000 type, |
995 NOT_IN_LOOP, | 1001 in_loop_, |
996 argc); | 1002 argc); |
997 return GetCodeWithFlags(flags, name); | 1003 return GetCodeWithFlags(flags, name); |
998 } | 1004 } |
999 | 1005 |
1000 | 1006 |
1001 } } // namespace v8::internal | 1007 } } // namespace v8::internal |
OLD | NEW |