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