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; | 2959 Label materialize_true, materialize_false, skip_lookup; |
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, if_true); | 2973 __ j(not_zero, &skip_lookup); |
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 25 matching lines...) Expand all Loading... |
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 // Reload map as register ebx was used as temporary above. | 3016 // Reload map as register ebx was used as temporary above. |
3017 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 3017 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
3018 | 3018 |
| 3019 // Set the bit in the map to indicate that there is no local valueOf field. |
| 3020 __ or_(FieldOperand(ebx, Map::kBitField2Offset), |
| 3021 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 3022 |
| 3023 __ bind(&skip_lookup); |
| 3024 |
3019 // If a valueOf property is not found on the object check that its | 3025 // If a valueOf property is not found on the object check that its |
3020 // prototype is the un-modified String prototype. If not result is false. | 3026 // prototype is the un-modified String prototype. If not result is false. |
3021 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); | 3027 __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); |
3022 __ JumpIfSmi(ecx, if_false); | 3028 __ JumpIfSmi(ecx, if_false); |
3023 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | 3029 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); |
3024 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3030 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
3025 __ mov(edx, | 3031 __ mov(edx, |
3026 FieldOperand(edx, GlobalObject::kNativeContextOffset)); | 3032 FieldOperand(edx, GlobalObject::kNativeContextOffset)); |
3027 __ cmp(ecx, | 3033 __ cmp(ecx, |
3028 ContextOperand(edx, | 3034 ContextOperand(edx, |
3029 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); | 3035 Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
3030 __ j(not_equal, if_false); | 3036 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
3031 __ jmp(if_true); | 3037 Split(equal, if_true, if_false, fall_through); |
3032 | 3038 |
3033 PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); | |
3034 context()->Plug(if_true, if_false); | 3039 context()->Plug(if_true, if_false); |
3035 } | 3040 } |
3036 | 3041 |
3037 | 3042 |
3038 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { | 3043 void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
3039 ZoneList<Expression*>* args = expr->arguments(); | 3044 ZoneList<Expression*>* args = expr->arguments(); |
3040 ASSERT(args->length() == 1); | 3045 ASSERT(args->length() == 1); |
3041 | 3046 |
3042 VisitForAccumulatorValue(args->at(0)); | 3047 VisitForAccumulatorValue(args->at(0)); |
3043 | 3048 |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4888 *stack_depth = 0; | 4893 *stack_depth = 0; |
4889 *context_length = 0; | 4894 *context_length = 0; |
4890 return previous_; | 4895 return previous_; |
4891 } | 4896 } |
4892 | 4897 |
4893 #undef __ | 4898 #undef __ |
4894 | 4899 |
4895 } } // namespace v8::internal | 4900 } } // namespace v8::internal |
4896 | 4901 |
4897 #endif // V8_TARGET_ARCH_IA32 | 4902 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |