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 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 stub = pre_monomorphic_stub(); | 872 stub = pre_monomorphic_stub(); |
873 } else if (state() == PREMONOMORPHIC || state() == MONOMORPHIC) { | 873 } else if (state() == PREMONOMORPHIC || state() == MONOMORPHIC) { |
874 StringLengthStub string_length_stub(kind()); | 874 StringLengthStub string_length_stub(kind()); |
875 stub = string_length_stub.GetCode(isolate()); | 875 stub = string_length_stub.GetCode(isolate()); |
876 } else if (state() != MEGAMORPHIC) { | 876 } else if (state() != MEGAMORPHIC) { |
877 ASSERT(state() != GENERIC); | 877 ASSERT(state() != GENERIC); |
878 stub = megamorphic_stub(); | 878 stub = megamorphic_stub(); |
879 } | 879 } |
880 if (!stub.is_null()) { | 880 if (!stub.is_null()) { |
881 set_target(*stub); | 881 set_target(*stub); |
882 #ifdef DEBUG | |
883 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /stringwrapper]\n"); | 882 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /stringwrapper]\n"); |
884 #endif | |
885 } | 883 } |
886 // Get the string if we have a string wrapper object. | 884 // Get the string if we have a string wrapper object. |
887 String* string = String::cast(JSValue::cast(*object)->value()); | 885 String* string = String::cast(JSValue::cast(*object)->value()); |
888 return Smi::FromInt(string->length()); | 886 return Smi::FromInt(string->length()); |
889 } | 887 } |
890 | 888 |
891 // Use specialized code for getting prototype of functions. | 889 // Use specialized code for getting prototype of functions. |
892 if (object->IsJSFunction() && | 890 if (object->IsJSFunction() && |
893 name->Equals(isolate()->heap()->prototype_string()) && | 891 name->Equals(isolate()->heap()->prototype_string()) && |
894 Handle<JSFunction>::cast(object)->should_have_prototype()) { | 892 Handle<JSFunction>::cast(object)->should_have_prototype()) { |
895 Handle<Code> stub; | 893 Handle<Code> stub; |
896 if (state() == UNINITIALIZED) { | 894 if (state() == UNINITIALIZED) { |
897 stub = pre_monomorphic_stub(); | 895 stub = pre_monomorphic_stub(); |
898 } else if (state() == PREMONOMORPHIC) { | 896 } else if (state() == PREMONOMORPHIC) { |
899 FunctionPrototypeStub function_prototype_stub(kind()); | 897 FunctionPrototypeStub function_prototype_stub(kind()); |
900 stub = function_prototype_stub.GetCode(isolate()); | 898 stub = function_prototype_stub.GetCode(isolate()); |
901 } else if (state() != MEGAMORPHIC) { | 899 } else if (state() != MEGAMORPHIC) { |
902 ASSERT(state() != GENERIC); | 900 ASSERT(state() != GENERIC); |
903 stub = megamorphic_stub(); | 901 stub = megamorphic_stub(); |
904 } | 902 } |
905 if (!stub.is_null()) { | 903 if (!stub.is_null()) { |
906 set_target(*stub); | 904 set_target(*stub); |
907 #ifdef DEBUG | |
908 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); | 905 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); |
909 #endif | |
910 } | 906 } |
911 return *Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object)); | 907 return *Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object)); |
912 } | 908 } |
913 } | 909 } |
914 | 910 |
915 // Check if the name is trivially convertible to an index and get | 911 // Check if the name is trivially convertible to an index and get |
916 // the element or char if so. | 912 // the element or char if so. |
917 uint32_t index; | 913 uint32_t index; |
918 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { | 914 if (kind() == Code::KEYED_LOAD_IC && name->AsArrayIndex(&index)) { |
919 // Rewrite to the generic keyed load stub. | 915 // Rewrite to the generic keyed load stub. |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 BinaryOpStub stub(extra_ic_state); | 2349 BinaryOpStub stub(extra_ic_state); |
2354 | 2350 |
2355 Handle<Type> left_type = stub.GetLeftType(isolate()); | 2351 Handle<Type> left_type = stub.GetLeftType(isolate()); |
2356 Handle<Type> right_type = stub.GetRightType(isolate()); | 2352 Handle<Type> right_type = stub.GetRightType(isolate()); |
2357 bool smi_was_enabled = left_type->Maybe(Type::Smi()) && | 2353 bool smi_was_enabled = left_type->Maybe(Type::Smi()) && |
2358 right_type->Maybe(Type::Smi()); | 2354 right_type->Maybe(Type::Smi()); |
2359 | 2355 |
2360 Maybe<Handle<Object> > result = stub.Result(left, right, isolate()); | 2356 Maybe<Handle<Object> > result = stub.Result(left, right, isolate()); |
2361 if (!result.has_value) return Failure::Exception(); | 2357 if (!result.has_value) return Failure::Exception(); |
2362 | 2358 |
2363 #ifdef DEBUG | |
2364 if (FLAG_trace_ic) { | 2359 if (FLAG_trace_ic) { |
2365 char buffer[100]; | 2360 char buffer[100]; |
2366 NoAllocationStringAllocator allocator(buffer, | 2361 NoAllocationStringAllocator allocator(buffer, |
2367 static_cast<unsigned>(sizeof(buffer))); | 2362 static_cast<unsigned>(sizeof(buffer))); |
2368 StringStream stream(&allocator); | 2363 StringStream stream(&allocator); |
2369 stream.Add("["); | 2364 stream.Add("["); |
2370 stub.PrintName(&stream); | 2365 stub.PrintName(&stream); |
2371 | 2366 |
2372 stub.UpdateStatus(left, right, result); | 2367 stub.UpdateStatus(left, right, result); |
2373 | 2368 |
2374 stream.Add(" => "); | 2369 stream.Add(" => "); |
2375 stub.PrintState(&stream); | 2370 stub.PrintState(&stream); |
2376 stream.Add(" "); | 2371 stream.Add(" "); |
2377 stream.OutputToStdOut(); | 2372 stream.OutputToStdOut(); |
2378 PrintF(" @ %p <- ", static_cast<void*>(*stub.GetCode(isolate()))); | 2373 PrintF(" @ %p <- ", static_cast<void*>(*stub.GetCode(isolate()))); |
2379 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); | 2374 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); |
2380 PrintF("]\n"); | 2375 PrintF("]\n"); |
2381 } else { | 2376 } else { |
2382 stub.UpdateStatus(left, right, result); | 2377 stub.UpdateStatus(left, right, result); |
2383 } | 2378 } |
2384 #else | |
2385 stub.UpdateStatus(left, right, result); | |
2386 #endif | |
2387 | 2379 |
2388 Handle<Code> code = stub.GetCode(isolate()); | 2380 Handle<Code> code = stub.GetCode(isolate()); |
2389 set_target(*code); | 2381 set_target(*code); |
2390 | 2382 |
2391 left_type = stub.GetLeftType(isolate()); | 2383 left_type = stub.GetLeftType(isolate()); |
2392 right_type = stub.GetRightType(isolate()); | 2384 right_type = stub.GetRightType(isolate()); |
2393 bool enable_smi = left_type->Maybe(Type::Smi()) && | 2385 bool enable_smi = left_type->Maybe(Type::Smi()) && |
2394 right_type->Maybe(Type::Smi()); | 2386 right_type->Maybe(Type::Smi()); |
2395 | 2387 |
2396 if (!smi_was_enabled && enable_smi) { | 2388 if (!smi_was_enabled && enable_smi) { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2605 State state = TargetState(previous_state, previous_left, previous_right, | 2597 State state = TargetState(previous_state, previous_left, previous_right, |
2606 HasInlinedSmiCode(address()), x, y); | 2598 HasInlinedSmiCode(address()), x, y); |
2607 ICCompareStub stub(op_, new_left, new_right, state); | 2599 ICCompareStub stub(op_, new_left, new_right, state); |
2608 if (state == KNOWN_OBJECT) { | 2600 if (state == KNOWN_OBJECT) { |
2609 stub.set_known_map( | 2601 stub.set_known_map( |
2610 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); | 2602 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); |
2611 } | 2603 } |
2612 Handle<Code> new_target = stub.GetCode(isolate()); | 2604 Handle<Code> new_target = stub.GetCode(isolate()); |
2613 set_target(*new_target); | 2605 set_target(*new_target); |
2614 | 2606 |
2615 #ifdef DEBUG | |
2616 if (FLAG_trace_ic) { | 2607 if (FLAG_trace_ic) { |
2617 PrintF("[CompareIC in "); | 2608 PrintF("[CompareIC in "); |
2618 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); | 2609 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); |
2619 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", | 2610 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", |
2620 GetStateName(previous_left), | 2611 GetStateName(previous_left), |
2621 GetStateName(previous_right), | 2612 GetStateName(previous_right), |
2622 GetStateName(previous_state), | 2613 GetStateName(previous_state), |
2623 GetStateName(new_left), | 2614 GetStateName(new_left), |
2624 GetStateName(new_right), | 2615 GetStateName(new_right), |
2625 GetStateName(state), | 2616 GetStateName(state), |
2626 Token::Name(op_), | 2617 Token::Name(op_), |
2627 static_cast<void*>(*stub.GetCode(isolate()))); | 2618 static_cast<void*>(*stub.GetCode(isolate()))); |
2628 } | 2619 } |
2629 #endif | |
2630 | 2620 |
2631 // Activate inlined smi code. | 2621 // Activate inlined smi code. |
2632 if (previous_state == UNINITIALIZED) { | 2622 if (previous_state == UNINITIALIZED) { |
2633 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); | 2623 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
2634 } | 2624 } |
2635 | 2625 |
2636 return *new_target; | 2626 return *new_target; |
2637 } | 2627 } |
2638 | 2628 |
2639 | 2629 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 #undef ADDR | 2768 #undef ADDR |
2779 }; | 2769 }; |
2780 | 2770 |
2781 | 2771 |
2782 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2772 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2783 return IC_utilities[id]; | 2773 return IC_utilities[id]; |
2784 } | 2774 } |
2785 | 2775 |
2786 | 2776 |
2787 } } // namespace v8::internal | 2777 } } // namespace v8::internal |
OLD | NEW |