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