OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 if (FLAG_watch_ic_patching) { | 368 if (FLAG_watch_ic_patching) { |
369 host->set_profiler_ticks(0); | 369 host->set_profiler_ticks(0); |
370 isolate->runtime_profiler()->NotifyICChanged(); | 370 isolate->runtime_profiler()->NotifyICChanged(); |
371 } | 371 } |
372 // TODO(2029): When an optimized function is patched, it would | 372 // TODO(2029): When an optimized function is patched, it would |
373 // be nice to propagate the corresponding type information to its | 373 // be nice to propagate the corresponding type information to its |
374 // unoptimized version for the benefit of later inlining. | 374 // unoptimized version for the benefit of later inlining. |
375 } | 375 } |
376 | 376 |
377 | 377 |
378 void IC::Clear(Address address) { | 378 void IC::Clear(Isolate* isolate, Address address) { |
379 Code* target = GetTargetAtAddress(address); | 379 Code* target = GetTargetAtAddress(address); |
380 | 380 |
381 // Don't clear debug break inline cache as it will remove the break point. | 381 // Don't clear debug break inline cache as it will remove the break point. |
382 if (target->is_debug_stub()) return; | 382 if (target->is_debug_stub()) return; |
383 | 383 |
384 switch (target->kind()) { | 384 switch (target->kind()) { |
385 case Code::LOAD_IC: return LoadIC::Clear(address, target); | 385 case Code::LOAD_IC: return LoadIC::Clear(isolate, address, target); |
386 case Code::KEYED_LOAD_IC: return KeyedLoadIC::Clear(address, target); | 386 case Code::KEYED_LOAD_IC: |
387 case Code::STORE_IC: return StoreIC::Clear(address, target); | 387 return KeyedLoadIC::Clear(isolate, address, target); |
388 case Code::KEYED_STORE_IC: return KeyedStoreIC::Clear(address, target); | 388 case Code::STORE_IC: return StoreIC::Clear(isolate, address, target); |
| 389 case Code::KEYED_STORE_IC: |
| 390 return KeyedStoreIC::Clear(isolate, address, target); |
389 case Code::CALL_IC: return CallIC::Clear(address, target); | 391 case Code::CALL_IC: return CallIC::Clear(address, target); |
390 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); | 392 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); |
391 case Code::COMPARE_IC: return CompareIC::Clear(address, target); | 393 case Code::COMPARE_IC: return CompareIC::Clear(isolate, address, target); |
392 case Code::COMPARE_NIL_IC: return CompareNilIC::Clear(address, target); | 394 case Code::COMPARE_NIL_IC: return CompareNilIC::Clear(address, target); |
393 case Code::BINARY_OP_IC: | 395 case Code::BINARY_OP_IC: |
394 case Code::TO_BOOLEAN_IC: | 396 case Code::TO_BOOLEAN_IC: |
395 // Clearing these is tricky and does not | 397 // Clearing these is tricky and does not |
396 // make any performance difference. | 398 // make any performance difference. |
397 return; | 399 return; |
398 default: UNREACHABLE(); | 400 default: UNREACHABLE(); |
399 } | 401 } |
400 } | 402 } |
401 | 403 |
402 | 404 |
403 void CallICBase::Clear(Address address, Code* target) { | 405 void CallICBase::Clear(Address address, Code* target) { |
404 if (target->ic_state() == UNINITIALIZED) return; | 406 if (target->ic_state() == UNINITIALIZED) return; |
405 bool contextual = CallICBase::Contextual::decode(target->extra_ic_state()); | 407 bool contextual = CallICBase::Contextual::decode(target->extra_ic_state()); |
406 Code* code = | 408 Code* code = |
407 Isolate::Current()->stub_cache()->FindCallInitialize( | 409 target->GetIsolate()->stub_cache()->FindCallInitialize( |
408 target->arguments_count(), | 410 target->arguments_count(), |
409 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, | 411 contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET, |
410 target->kind()); | 412 target->kind()); |
411 SetTargetAtAddress(address, code); | 413 SetTargetAtAddress(address, code); |
412 } | 414 } |
413 | 415 |
414 | 416 |
415 void KeyedLoadIC::Clear(Address address, Code* target) { | 417 void KeyedLoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
416 if (target->ic_state() == UNINITIALIZED) return; | 418 if (target->ic_state() == UNINITIALIZED) return; |
417 // Make sure to also clear the map used in inline fast cases. If we | 419 // Make sure to also clear the map used in inline fast cases. If we |
418 // do not clear these maps, cached code can keep objects alive | 420 // do not clear these maps, cached code can keep objects alive |
419 // through the embedded maps. | 421 // through the embedded maps. |
420 SetTargetAtAddress(address, *initialize_stub()); | 422 SetTargetAtAddress(address, *initialize_stub(isolate)); |
421 } | 423 } |
422 | 424 |
423 | 425 |
424 void LoadIC::Clear(Address address, Code* target) { | 426 void LoadIC::Clear(Isolate* isolate, Address address, Code* target) { |
425 if (target->ic_state() == UNINITIALIZED) return; | 427 if (target->ic_state() == UNINITIALIZED) return; |
426 SetTargetAtAddress(address, *initialize_stub()); | 428 SetTargetAtAddress(address, *initialize_stub(isolate)); |
427 } | 429 } |
428 | 430 |
429 | 431 |
430 void StoreIC::Clear(Address address, Code* target) { | 432 void StoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
431 if (target->ic_state() == UNINITIALIZED) return; | 433 if (target->ic_state() == UNINITIALIZED) return; |
432 SetTargetAtAddress(address, | 434 SetTargetAtAddress(address, |
433 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode) | 435 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode) |
434 ? *initialize_stub_strict() | 436 ? *initialize_stub_strict(isolate) |
435 : *initialize_stub()); | 437 : *initialize_stub(isolate)); |
436 } | 438 } |
437 | 439 |
438 | 440 |
439 void KeyedStoreIC::Clear(Address address, Code* target) { | 441 void KeyedStoreIC::Clear(Isolate* isolate, Address address, Code* target) { |
440 if (target->ic_state() == UNINITIALIZED) return; | 442 if (target->ic_state() == UNINITIALIZED) return; |
441 SetTargetAtAddress(address, | 443 SetTargetAtAddress(address, |
442 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode) | 444 (Code::GetStrictMode(target->extra_ic_state()) == kStrictMode) |
443 ? *initialize_stub_strict() | 445 ? *initialize_stub_strict(isolate) |
444 : *initialize_stub()); | 446 : *initialize_stub(isolate)); |
445 } | 447 } |
446 | 448 |
447 | 449 |
448 void CompareIC::Clear(Address address, Code* target) { | 450 void CompareIC::Clear(Isolate* isolate, Address address, Code* target) { |
449 ASSERT(target->major_key() == CodeStub::CompareIC); | 451 ASSERT(target->major_key() == CodeStub::CompareIC); |
450 CompareIC::State handler_state; | 452 CompareIC::State handler_state; |
451 Token::Value op; | 453 Token::Value op; |
452 ICCompareStub::DecodeMinorKey(target->stub_info(), NULL, NULL, | 454 ICCompareStub::DecodeMinorKey(target->stub_info(), NULL, NULL, |
453 &handler_state, &op); | 455 &handler_state, &op); |
454 // Only clear CompareICs that can retain objects. | 456 // Only clear CompareICs that can retain objects. |
455 if (handler_state != KNOWN_OBJECT) return; | 457 if (handler_state != KNOWN_OBJECT) return; |
456 SetTargetAtAddress(address, GetRawUninitialized(op)); | 458 SetTargetAtAddress(address, GetRawUninitialized(isolate, op)); |
457 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); | 459 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); |
458 } | 460 } |
459 | 461 |
460 | 462 |
461 static bool HasInterceptorGetter(JSObject* object) { | 463 static bool HasInterceptorGetter(JSObject* object) { |
462 return !object->GetNamedInterceptor()->getter()->IsUndefined(); | 464 return !object->GetNamedInterceptor()->getter()->IsUndefined(); |
463 } | 465 } |
464 | 466 |
465 | 467 |
466 static void LookupForRead(Handle<Object> object, | 468 static void LookupForRead(Handle<Object> object, |
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 ARRAY_SIZE(builtin_args), | 2766 ARRAY_SIZE(builtin_args), |
2765 builtin_args, | 2767 builtin_args, |
2766 &caught_exception); | 2768 &caught_exception); |
2767 if (caught_exception) { | 2769 if (caught_exception) { |
2768 return Failure::Exception(); | 2770 return Failure::Exception(); |
2769 } | 2771 } |
2770 return *result; | 2772 return *result; |
2771 } | 2773 } |
2772 | 2774 |
2773 | 2775 |
2774 Code* CompareIC::GetRawUninitialized(Token::Value op) { | 2776 Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op) { |
2775 ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); | 2777 ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); |
2776 Code* code = NULL; | 2778 Code* code = NULL; |
2777 CHECK(stub.FindCodeInCache(&code, Isolate::Current())); | 2779 CHECK(stub.FindCodeInCache(&code, isolate)); |
2778 return code; | 2780 return code; |
2779 } | 2781 } |
2780 | 2782 |
2781 | 2783 |
2782 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op) { | 2784 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op) { |
2783 ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); | 2785 ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); |
2784 return stub.GetCode(isolate); | 2786 return stub.GetCode(isolate); |
2785 } | 2787 } |
2786 | 2788 |
2787 | 2789 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3095 #undef ADDR | 3097 #undef ADDR |
3096 }; | 3098 }; |
3097 | 3099 |
3098 | 3100 |
3099 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3101 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3100 return IC_utilities[id]; | 3102 return IC_utilities[id]; |
3101 } | 3103 } |
3102 | 3104 |
3103 | 3105 |
3104 } } // namespace v8::internal | 3106 } } // namespace v8::internal |
OLD | NEW |