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