| 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 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2930 } | 2930 } |
| 2931 | 2931 |
| 2932 | 2932 |
| 2933 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( | 2933 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
| 2934 CallRuntime* expr) { | 2934 CallRuntime* expr) { |
| 2935 ZoneList<Expression*>* args = expr->arguments(); | 2935 ZoneList<Expression*>* args = expr->arguments(); |
| 2936 ASSERT(args->length() == 1); | 2936 ASSERT(args->length() == 1); |
| 2937 | 2937 |
| 2938 VisitForAccumulatorValue(args->at(0)); | 2938 VisitForAccumulatorValue(args->at(0)); |
| 2939 | 2939 |
| 2940 Label materialize_true, materialize_false; | 2940 Label materialize_true, materialize_false, skip_lookup; |
| 2941 Label* if_true = NULL; | 2941 Label* if_true = NULL; |
| 2942 Label* if_false = NULL; | 2942 Label* if_false = NULL; |
| 2943 Label* fall_through = NULL; | 2943 Label* fall_through = NULL; |
| 2944 context()->PrepareTest(&materialize_true, &materialize_false, | 2944 context()->PrepareTest(&materialize_true, &materialize_false, |
| 2945 &if_true, &if_false, &fall_through); | 2945 &if_true, &if_false, &fall_through); |
| 2946 | 2946 |
| 2947 __ AssertNotSmi(rax); | 2947 __ AssertNotSmi(rax); |
| 2948 | 2948 |
| 2949 // Check whether this map has already been checked to be safe for default | 2949 // Check whether this map has already been checked to be safe for default |
| 2950 // valueOf. | 2950 // valueOf. |
| 2951 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 2951 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 2952 __ testb(FieldOperand(rbx, Map::kBitField2Offset), | 2952 __ testb(FieldOperand(rbx, Map::kBitField2Offset), |
| 2953 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | 2953 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 2954 __ j(not_zero, if_true); | 2954 __ j(not_zero, &skip_lookup); |
| 2955 | 2955 |
| 2956 // Check for fast case object. Generate false result for slow case object. | 2956 // Check for fast case object. Generate false result for slow case object. |
| 2957 __ movq(rcx, FieldOperand(rax, JSObject::kPropertiesOffset)); | 2957 __ movq(rcx, FieldOperand(rax, JSObject::kPropertiesOffset)); |
| 2958 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); | 2958 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); |
| 2959 __ CompareRoot(rcx, Heap::kHashTableMapRootIndex); | 2959 __ CompareRoot(rcx, Heap::kHashTableMapRootIndex); |
| 2960 __ j(equal, if_false); | 2960 __ j(equal, if_false); |
| 2961 | 2961 |
| 2962 // Look for valueOf string in the descriptor array, and indicate false if | 2962 // Look for valueOf string in the descriptor array, and indicate false if |
| 2963 // found. Since we omit an enumeration index check, if it is added via a | 2963 // found. Since we omit an enumeration index check, if it is added via a |
| 2964 // transition that shares its descriptor array, this is a false positive. | 2964 // transition that shares its descriptor array, this is a false positive. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2986 __ bind(&loop); | 2986 __ bind(&loop); |
| 2987 __ movq(rdx, FieldOperand(rbx, 0)); | 2987 __ movq(rdx, FieldOperand(rbx, 0)); |
| 2988 __ Cmp(rdx, isolate()->factory()->value_of_string()); | 2988 __ Cmp(rdx, isolate()->factory()->value_of_string()); |
| 2989 __ j(equal, if_false); | 2989 __ j(equal, if_false); |
| 2990 __ addq(rbx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); | 2990 __ addq(rbx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); |
| 2991 __ bind(&entry); | 2991 __ bind(&entry); |
| 2992 __ cmpq(rbx, rcx); | 2992 __ cmpq(rbx, rcx); |
| 2993 __ j(not_equal, &loop); | 2993 __ j(not_equal, &loop); |
| 2994 | 2994 |
| 2995 __ bind(&done); | 2995 __ bind(&done); |
| 2996 |
| 2997 // Set the bit in the map to indicate that there is no local valueOf field. |
| 2998 __ or_(FieldOperand(rbx, Map::kBitField2Offset), |
| 2999 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 3000 |
| 2996 // Reload map as register rbx was used as temporary above. | 3001 // Reload map as register rbx was used as temporary above. |
| 2997 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | 3002 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 2998 | 3003 |
| 3004 __ bind(&skip_lookup); |
| 3005 |
| 2999 // If a valueOf property is not found on the object check that its | 3006 // If a valueOf property is not found on the object check that its |
| 3000 // prototype is the un-modified String prototype. If not result is false. | 3007 // prototype is the un-modified String prototype. If not result is false. |
| 3001 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); | 3008 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
| 3002 __ testq(rcx, Immediate(kSmiTagMask)); | 3009 __ testq(rcx, Immediate(kSmiTagMask)); |
| 3003 __ j(zero, if_false); | 3010 __ j(zero, if_false); |
| 3004 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); | 3011 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); |
| 3005 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3012 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
| 3006 __ movq(rdx, FieldOperand(rdx, GlobalObject::kNativeContextOffset)); | 3013 __ movq(rdx, FieldOperand(rdx, GlobalObject::kNativeContextOffset)); |
| 3007 __ cmpq(rcx, | 3014 __ cmpq(rcx, |
| 3008 ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 3015 ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 3009 __ j(not_equal, if_false); | 3016 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3010 __ jmp(if_true); | 3017 Split(equal, if_true, if_false, fall_through); |
| 3011 | 3018 |
| 3012 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | |
| 3013 context()->Plug(if_true, if_false); | 3019 context()->Plug(if_true, if_false); |
| 3014 } | 3020 } |
| 3015 | 3021 |
| 3016 | 3022 |
| 3017 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3023 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
| 3018 ZoneList<Expression*>* args = expr->arguments(); | 3024 ZoneList<Expression*>* args = expr->arguments(); |
| 3019 ASSERT(args->length() == 1); | 3025 ASSERT(args->length() == 1); |
| 3020 | 3026 |
| 3021 VisitForAccumulatorValue(args->at(0)); | 3027 VisitForAccumulatorValue(args->at(0)); |
| 3022 | 3028 |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4878 *context_length = 0; | 4884 *context_length = 0; |
| 4879 return previous_; | 4885 return previous_; |
| 4880 } | 4886 } |
| 4881 | 4887 |
| 4882 | 4888 |
| 4883 #undef __ | 4889 #undef __ |
| 4884 | 4890 |
| 4885 } } // namespace v8::internal | 4891 } } // namespace v8::internal |
| 4886 | 4892 |
| 4887 #endif // V8_TARGET_ARCH_X64 | 4893 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |