OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 } | 557 } |
558 | 558 |
559 | 559 |
560 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, | 560 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, |
561 Address constant_pool) { | 561 Address constant_pool) { |
562 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); | 562 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); |
563 CompareICStub stub(target->stub_key(), isolate); | 563 CompareICStub stub(target->stub_key(), isolate); |
564 // Only clear CompareICs that can retain objects. | 564 // Only clear CompareICs that can retain objects. |
565 if (stub.state() != CompareICState::KNOWN_OBJECT) return; | 565 if (stub.state() != CompareICState::KNOWN_OBJECT) return; |
566 SetTargetAtAddress(address, | 566 SetTargetAtAddress(address, |
567 GetRawUninitialized(isolate, stub.op(), stub.strong()), | 567 GetRawUninitialized(isolate, stub.op(), stub.strength()), |
568 constant_pool); | 568 constant_pool); |
569 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); | 569 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); |
570 } | 570 } |
571 | 571 |
572 | 572 |
573 // static | 573 // static |
574 Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate) { | 574 Handle<Code> KeyedLoadIC::ChooseMegamorphicStub(Isolate* isolate) { |
575 if (FLAG_compiled_keyed_generic_loads) { | 575 if (FLAG_compiled_keyed_generic_loads) { |
576 return KeyedLoadGenericStub(isolate).GetCode(); | 576 return KeyedLoadGenericStub(isolate).GetCode(); |
577 } else { | 577 } else { |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 } | 2424 } |
2425 | 2425 |
2426 | 2426 |
2427 MaybeHandle<Object> BinaryOpIC::Transition( | 2427 MaybeHandle<Object> BinaryOpIC::Transition( |
2428 Handle<AllocationSite> allocation_site, Handle<Object> left, | 2428 Handle<AllocationSite> allocation_site, Handle<Object> left, |
2429 Handle<Object> right) { | 2429 Handle<Object> right) { |
2430 BinaryOpICState state(isolate(), target()->extra_ic_state()); | 2430 BinaryOpICState state(isolate(), target()->extra_ic_state()); |
2431 | 2431 |
2432 // Compute the actual result using the builtin for the binary operation. | 2432 // Compute the actual result using the builtin for the binary operation. |
2433 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( | 2433 Object* builtin = isolate()->js_builtins_object()->javascript_builtin( |
2434 TokenToJSBuiltin(state.op(), state.language_mode())); | 2434 TokenToJSBuiltin(state.op(), state.strength())); |
2435 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); | 2435 Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); |
2436 Handle<Object> result; | 2436 Handle<Object> result; |
2437 ASSIGN_RETURN_ON_EXCEPTION( | 2437 ASSIGN_RETURN_ON_EXCEPTION( |
2438 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), | 2438 isolate(), result, Execution::Call(isolate(), function, left, 1, &right), |
2439 Object); | 2439 Object); |
2440 | 2440 |
2441 // Do not try to update the target if the code was marked for lazy | 2441 // Do not try to update the target if the code was marked for lazy |
2442 // deoptimization. (Since we do not relocate addresses in these | 2442 // deoptimization. (Since we do not relocate addresses in these |
2443 // code objects, an attempt to access the target could fail.) | 2443 // code objects, an attempt to access the target could fail.) |
2444 if (AddressIsDeoptimizedCode()) { | 2444 if (AddressIsDeoptimizedCode()) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 args.at<Object>(BinaryOpWithAllocationSiteStub::kRight); | 2525 args.at<Object>(BinaryOpWithAllocationSiteStub::kRight); |
2526 BinaryOpIC ic(isolate); | 2526 BinaryOpIC ic(isolate); |
2527 Handle<Object> result; | 2527 Handle<Object> result; |
2528 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2528 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2529 isolate, result, ic.Transition(allocation_site, left, right)); | 2529 isolate, result, ic.Transition(allocation_site, left, right)); |
2530 return *result; | 2530 return *result; |
2531 } | 2531 } |
2532 | 2532 |
2533 | 2533 |
2534 Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op, | 2534 Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op, |
2535 bool strong) { | 2535 Strength strength) { |
2536 CompareICStub stub(isolate, op, strong, CompareICState::UNINITIALIZED, | 2536 CompareICStub stub(isolate, op, strength, CompareICState::UNINITIALIZED, |
2537 CompareICState::UNINITIALIZED, | 2537 CompareICState::UNINITIALIZED, |
2538 CompareICState::UNINITIALIZED); | 2538 CompareICState::UNINITIALIZED); |
2539 Code* code = NULL; | 2539 Code* code = NULL; |
2540 CHECK(stub.FindCodeInCache(&code)); | 2540 CHECK(stub.FindCodeInCache(&code)); |
2541 return code; | 2541 return code; |
2542 } | 2542 } |
2543 | 2543 |
2544 | 2544 |
2545 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op, | 2545 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op, |
2546 bool strong) { | 2546 Strength strength) { |
2547 CompareICStub stub(isolate, op, strong, CompareICState::UNINITIALIZED, | 2547 CompareICStub stub(isolate, op, strength, CompareICState::UNINITIALIZED, |
2548 CompareICState::UNINITIALIZED, | 2548 CompareICState::UNINITIALIZED, |
2549 CompareICState::UNINITIALIZED); | 2549 CompareICState::UNINITIALIZED); |
2550 return stub.GetCode(); | 2550 return stub.GetCode(); |
2551 } | 2551 } |
2552 | 2552 |
2553 | 2553 |
2554 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { | 2554 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
2555 HandleScope scope(isolate()); | 2555 HandleScope scope(isolate()); |
2556 CompareICStub old_stub(target()->stub_key(), isolate()); | 2556 CompareICStub old_stub(target()->stub_key(), isolate()); |
2557 CompareICState::State new_left = | 2557 CompareICState::State new_left = |
2558 CompareICState::NewInputState(old_stub.left(), x); | 2558 CompareICState::NewInputState(old_stub.left(), x); |
2559 CompareICState::State new_right = | 2559 CompareICState::State new_right = |
2560 CompareICState::NewInputState(old_stub.right(), y); | 2560 CompareICState::NewInputState(old_stub.right(), y); |
2561 CompareICState::State state = CompareICState::TargetState( | 2561 CompareICState::State state = CompareICState::TargetState( |
2562 old_stub.state(), old_stub.left(), old_stub.right(), op_, | 2562 old_stub.state(), old_stub.left(), old_stub.right(), op_, |
2563 HasInlinedSmiCode(address()), x, y); | 2563 HasInlinedSmiCode(address()), x, y); |
2564 CompareICStub stub(isolate(), op_, old_stub.strong(), new_left, new_right, | 2564 CompareICStub stub(isolate(), op_, old_stub.strength(), new_left, new_right, |
2565 state); | 2565 state); |
2566 if (state == CompareICState::KNOWN_OBJECT) { | 2566 if (state == CompareICState::KNOWN_OBJECT) { |
2567 stub.set_known_map( | 2567 stub.set_known_map( |
2568 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); | 2568 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); |
2569 } | 2569 } |
2570 Handle<Code> new_target = stub.GetCode(); | 2570 Handle<Code> new_target = stub.GetCode(); |
2571 set_target(*new_target); | 2571 set_target(*new_target); |
2572 | 2572 |
2573 if (FLAG_trace_ic) { | 2573 if (FLAG_trace_ic) { |
2574 PrintF("[CompareIC in "); | 2574 PrintF("[CompareIC in "); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 | 2664 |
2665 | 2665 |
2666 RUNTIME_FUNCTION(Unreachable) { | 2666 RUNTIME_FUNCTION(Unreachable) { |
2667 UNREACHABLE(); | 2667 UNREACHABLE(); |
2668 CHECK(false); | 2668 CHECK(false); |
2669 return isolate->heap()->undefined_value(); | 2669 return isolate->heap()->undefined_value(); |
2670 } | 2670 } |
2671 | 2671 |
2672 | 2672 |
2673 Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op, | 2673 Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op, |
2674 LanguageMode language_mode) { | 2674 Strength strength) { |
2675 if (is_strong(language_mode)) { | 2675 if (is_strong(strength)) { |
2676 switch (op) { | 2676 switch (op) { |
2677 default: UNREACHABLE(); | 2677 default: UNREACHABLE(); |
2678 case Token::ADD: return Builtins::ADD_STRONG; | 2678 case Token::ADD: return Builtins::ADD_STRONG; |
2679 case Token::SUB: return Builtins::SUB_STRONG; | 2679 case Token::SUB: return Builtins::SUB_STRONG; |
2680 case Token::MUL: return Builtins::MUL_STRONG; | 2680 case Token::MUL: return Builtins::MUL_STRONG; |
2681 case Token::DIV: return Builtins::DIV_STRONG; | 2681 case Token::DIV: return Builtins::DIV_STRONG; |
2682 case Token::MOD: return Builtins::MOD_STRONG; | 2682 case Token::MOD: return Builtins::MOD_STRONG; |
2683 case Token::BIT_OR: return Builtins::BIT_OR_STRONG; | 2683 case Token::BIT_OR: return Builtins::BIT_OR_STRONG; |
2684 case Token::BIT_AND: return Builtins::BIT_AND_STRONG; | 2684 case Token::BIT_AND: return Builtins::BIT_AND_STRONG; |
2685 case Token::BIT_XOR: return Builtins::BIT_XOR_STRONG; | 2685 case Token::BIT_XOR: return Builtins::BIT_XOR_STRONG; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 static const Address IC_utilities[] = { | 2897 static const Address IC_utilities[] = { |
2898 #define ADDR(name) FUNCTION_ADDR(name), | 2898 #define ADDR(name) FUNCTION_ADDR(name), |
2899 IC_UTIL_LIST(ADDR) NULL | 2899 IC_UTIL_LIST(ADDR) NULL |
2900 #undef ADDR | 2900 #undef ADDR |
2901 }; | 2901 }; |
2902 | 2902 |
2903 | 2903 |
2904 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 2904 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
2905 } // namespace internal | 2905 } // namespace internal |
2906 } // namespace v8 | 2906 } // namespace v8 |
OLD | NEW |