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 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2949 } | 2949 } |
2950 | 2950 |
2951 | 2951 |
2952 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( | 2952 void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
2953 CallRuntime* expr) { | 2953 CallRuntime* expr) { |
2954 ZoneList<Expression*>* args = expr->arguments(); | 2954 ZoneList<Expression*>* args = expr->arguments(); |
2955 ASSERT(args->length() == 1); | 2955 ASSERT(args->length() == 1); |
2956 | 2956 |
2957 VisitForAccumulatorValue(args->at(0)); | 2957 VisitForAccumulatorValue(args->at(0)); |
2958 | 2958 |
2959 Label materialize_true, materialize_false, skip_lookup; | 2959 Label materialize_true, materialize_false; |
2960 Label* if_true = NULL; | 2960 Label* if_true = NULL; |
2961 Label* if_false = NULL; | 2961 Label* if_false = NULL; |
2962 Label* fall_through = NULL; | 2962 Label* fall_through = NULL; |
2963 context()->PrepareTest(&materialize_true, &materialize_false, | 2963 context()->PrepareTest(&materialize_true, &materialize_false, |
2964 &if_true, &if_false, &fall_through); | 2964 &if_true, &if_false, &fall_through); |
2965 | 2965 |
2966 __ AssertNotSmi(eax); | 2966 __ AssertNotSmi(eax); |
2967 | 2967 |
2968 // Check whether this map has already been checked to be safe for default | 2968 // Check whether this map has already been checked to be safe for default |
2969 // valueOf. | 2969 // valueOf. |
2970 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 2970 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
2971 __ test_b(FieldOperand(ebx, Map::kBitField2Offset), | 2971 __ test_b(FieldOperand(ebx, Map::kBitField2Offset), |
2972 1 << Map::kStringWrapperSafeForDefaultValueOf); | 2972 1 << Map::kStringWrapperSafeForDefaultValueOf); |
2973 __ j(not_zero, &skip_lookup); | 2973 __ j(not_zero, if_true); |
2974 | 2974 |
2975 // Check for fast case object. Return false for slow case objects. | 2975 // Check for fast case object. Return false for slow case objects. |
2976 __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset)); | 2976 __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset)); |
2977 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | 2977 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); |
2978 __ cmp(ecx, isolate()->factory()->hash_table_map()); | 2978 __ cmp(ecx, isolate()->factory()->hash_table_map()); |
2979 __ j(equal, if_false); | 2979 __ j(equal, if_false); |
2980 | 2980 |
2981 // Look for valueOf string in the descriptor array, and indicate false if | 2981 // Look for valueOf string in the descriptor array, and indicate false if |
2982 // found. Since we omit an enumeration index check, if it is added via a | 2982 // found. Since we omit an enumeration index check, if it is added via a |
2983 // transition that shares its descriptor array, this is a false positive. | 2983 // transition that shares its descriptor array, this is a false positive. |
(...skipping 22 matching lines...) Expand all Loading... |
3006 __ mov(edx, FieldOperand(ebx, 0)); | 3006 __ mov(edx, FieldOperand(ebx, 0)); |
3007 __ cmp(edx, isolate()->factory()->value_of_string()); | 3007 __ cmp(edx, isolate()->factory()->value_of_string()); |
3008 __ j(equal, if_false); | 3008 __ j(equal, if_false); |
3009 __ add(ebx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); | 3009 __ add(ebx, Immediate(DescriptorArray::kDescriptorSize * kPointerSize)); |
3010 __ bind(&entry); | 3010 __ bind(&entry); |
3011 __ cmp(ebx, ecx); | 3011 __ cmp(ebx, ecx); |
3012 __ j(not_equal, &loop); | 3012 __ j(not_equal, &loop); |
3013 | 3013 |
3014 __ bind(&done); | 3014 __ bind(&done); |
3015 | 3015 |
3016 // Set the bit in the map to indicate that there is no local valueOf field. | |
3017 __ or_(FieldOperand(ebx, Map::kBitField2Offset), | |
3018 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); | |
3019 | |
3020 // Reload map as register ebx was used as temporary above. | 3016 // Reload map as register ebx was used as temporary above. |
3021 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 3017 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
3022 | 3018 |
3023 __ bind(&skip_lookup); | |
3024 | |
3025 // If a valueOf property is not found on the object check that its | 3019 // If a valueOf property is not found on the object check that its |
3026 // prototype is the un-modified String prototype. If not result is false. | 3020 // prototype is the un-modified String prototype. If not result is false. |
3027 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 3021 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
3028 __ JumpIfSmi(ecx, if_false); | 3022 __ JumpIfSmi(ecx, if_false); |
3029 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | 3023 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); |
3030 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3024 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
3031 __ mov(edx, | 3025 __ mov(edx, |
3032 FieldOperand(edx, GlobalObject::kNativeContextOffset)); | 3026 FieldOperand(edx, GlobalObject::kNativeContextOffset)); |
3033 __ cmp(ecx, | 3027 __ cmp(ecx, |
3034 ContextOperand(edx, | 3028 ContextOperand(edx, |
3035 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 3029 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 3030 __ j(not_equal, if_false); |
| 3031 __ jmp(if_true); |
| 3032 |
3036 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | 3033 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3037 Split(equal, if_true, if_false, fall_through); | |
3038 | |
3039 context()->Plug(if_true, if_false); | 3034 context()->Plug(if_true, if_false); |
3040 } | 3035 } |
3041 | 3036 |
3042 | 3037 |
3043 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3038 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
3044 ZoneList<Expression*>* args = expr->arguments(); | 3039 ZoneList<Expression*>* args = expr->arguments(); |
3045 ASSERT(args->length() == 1); | 3040 ASSERT(args->length() == 1); |
3046 | 3041 |
3047 VisitForAccumulatorValue(args->at(0)); | 3042 VisitForAccumulatorValue(args->at(0)); |
3048 | 3043 |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4893 *stack_depth = 0; | 4888 *stack_depth = 0; |
4894 *context_length = 0; | 4889 *context_length = 0; |
4895 return previous_; | 4890 return previous_; |
4896 } | 4891 } |
4897 | 4892 |
4898 #undef __ | 4893 #undef __ |
4899 | 4894 |
4900 } } // namespace v8::internal | 4895 } } // namespace v8::internal |
4901 | 4896 |
4902 #endif // V8_TARGET_ARCH_IA32 | 4897 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |