Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 osr_pc_offset_ = masm()->pc_offset(); | 266 osr_pc_offset_ = masm()->pc_offset(); |
| 267 | 267 |
| 268 // Adjust the frame size, subsuming the unoptimized frame into the | 268 // Adjust the frame size, subsuming the unoptimized frame into the |
| 269 // optimized frame. | 269 // optimized frame. |
| 270 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); | 270 int slots = GetStackSlotCount() - graph()->osr()->UnoptimizedFrameSlots(); |
| 271 ASSERT(slots >= 0); | 271 ASSERT(slots >= 0); |
| 272 __ subq(rsp, Immediate(slots * kPointerSize)); | 272 __ subq(rsp, Immediate(slots * kPointerSize)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 | 275 |
| 276 void LCodeGen::GenerateBodyInstructionPost(LInstruction* instr) { | |
| 277 if (instr->HasResult() && instr->MustSignExtendResult(chunk())) { | |
| 278 Register result_reg = ToRegister(instr->result()); | |
|
danno
2014/03/18 08:21:31
I think this might be a problem for some HValues t
Weiliang
2014/03/19 08:55:31
The testcase shows a HChange between HParameters a
| |
| 279 __ movsxlq(result_reg, result_reg); | |
| 280 } | |
| 281 } | |
| 282 | |
| 283 | |
| 276 bool LCodeGen::GenerateJumpTable() { | 284 bool LCodeGen::GenerateJumpTable() { |
| 277 Label needs_frame; | 285 Label needs_frame; |
| 278 if (jump_table_.length() > 0) { | 286 if (jump_table_.length() > 0) { |
| 279 Comment(";;; -------------------- Jump table --------------------"); | 287 Comment(";;; -------------------- Jump table --------------------"); |
| 280 } | 288 } |
| 281 for (int i = 0; i < jump_table_.length(); i++) { | 289 for (int i = 0; i < jump_table_.length(); i++) { |
| 282 __ bind(&jump_table_[i].label); | 290 __ bind(&jump_table_[i].label); |
| 283 Address entry = jump_table_[i].address; | 291 Address entry = jump_table_[i].address; |
| 284 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 292 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; |
| 285 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 293 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| (...skipping 2575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2861 StackArgumentsAccessor args(arguments, length, | 2869 StackArgumentsAccessor args(arguments, length, |
| 2862 ARGUMENTS_DONT_CONTAIN_RECEIVER); | 2870 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 2863 __ movp(result, args.GetArgumentOperand(0)); | 2871 __ movp(result, args.GetArgumentOperand(0)); |
| 2864 } | 2872 } |
| 2865 } | 2873 } |
| 2866 | 2874 |
| 2867 | 2875 |
| 2868 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { | 2876 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) { |
| 2869 ElementsKind elements_kind = instr->elements_kind(); | 2877 ElementsKind elements_kind = instr->elements_kind(); |
| 2870 LOperand* key = instr->key(); | 2878 LOperand* key = instr->key(); |
| 2871 if (!key->IsConstantOperand()) { | |
| 2872 Register key_reg = ToRegister(key); | |
| 2873 // Even though the HLoad/StoreKeyed (in this case) instructions force | |
| 2874 // the input representation for the key to be an integer, the input | |
| 2875 // gets replaced during bound check elimination with the index argument | |
| 2876 // to the bounds check, which can be tagged, so that case must be | |
| 2877 // handled here, too. | |
| 2878 if (instr->hydrogen()->IsDehoisted()) { | |
| 2879 // Sign extend key because it could be a 32 bit negative value | |
| 2880 // and the dehoisted address computation happens in 64 bits | |
| 2881 __ movsxlq(key_reg, key_reg); | |
| 2882 } | |
| 2883 } | |
| 2884 int base_offset = instr->is_fixed_typed_array() | 2879 int base_offset = instr->is_fixed_typed_array() |
| 2885 ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag | 2880 ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag |
| 2886 : 0; | 2881 : 0; |
| 2887 Operand operand(BuildFastArrayOperand( | 2882 Operand operand(BuildFastArrayOperand( |
| 2888 instr->elements(), | 2883 instr->elements(), |
| 2889 key, | 2884 key, |
| 2890 elements_kind, | 2885 elements_kind, |
| 2891 base_offset, | 2886 base_offset, |
| 2892 instr->additional_index())); | 2887 instr->additional_index())); |
| 2893 | 2888 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2947 UNREACHABLE(); | 2942 UNREACHABLE(); |
| 2948 break; | 2943 break; |
| 2949 } | 2944 } |
| 2950 } | 2945 } |
| 2951 } | 2946 } |
| 2952 | 2947 |
| 2953 | 2948 |
| 2954 void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { | 2949 void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) { |
| 2955 XMMRegister result(ToDoubleRegister(instr->result())); | 2950 XMMRegister result(ToDoubleRegister(instr->result())); |
| 2956 LOperand* key = instr->key(); | 2951 LOperand* key = instr->key(); |
| 2957 if (!key->IsConstantOperand()) { | |
| 2958 Register key_reg = ToRegister(key); | |
| 2959 // Even though the HLoad/StoreKeyed instructions force the input | |
| 2960 // representation for the key to be an integer, the input gets replaced | |
| 2961 // during bound check elimination with the index argument to the bounds | |
| 2962 // check, which can be tagged, so that case must be handled here, too. | |
| 2963 if (instr->hydrogen()->IsDehoisted()) { | |
| 2964 // Sign extend key because it could be a 32 bit negative value | |
| 2965 // and the dehoisted address computation happens in 64 bits | |
| 2966 __ movsxlq(key_reg, key_reg); | |
| 2967 } | |
| 2968 } | |
| 2969 | |
| 2970 if (instr->hydrogen()->RequiresHoleCheck()) { | 2952 if (instr->hydrogen()->RequiresHoleCheck()) { |
| 2971 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + | 2953 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
| 2972 sizeof(kHoleNanLower32); | 2954 sizeof(kHoleNanLower32); |
| 2973 Operand hole_check_operand = BuildFastArrayOperand( | 2955 Operand hole_check_operand = BuildFastArrayOperand( |
| 2974 instr->elements(), | 2956 instr->elements(), |
| 2975 key, | 2957 key, |
| 2976 FAST_DOUBLE_ELEMENTS, | 2958 FAST_DOUBLE_ELEMENTS, |
| 2977 offset, | 2959 offset, |
| 2978 instr->additional_index()); | 2960 instr->additional_index()); |
| 2979 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); | 2961 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); |
| 2980 DeoptimizeIf(equal, instr->environment()); | 2962 DeoptimizeIf(equal, instr->environment()); |
| 2981 } | 2963 } |
| 2982 | 2964 |
| 2983 Operand double_load_operand = BuildFastArrayOperand( | 2965 Operand double_load_operand = BuildFastArrayOperand( |
| 2984 instr->elements(), | 2966 instr->elements(), |
| 2985 key, | 2967 key, |
| 2986 FAST_DOUBLE_ELEMENTS, | 2968 FAST_DOUBLE_ELEMENTS, |
| 2987 FixedDoubleArray::kHeaderSize - kHeapObjectTag, | 2969 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| 2988 instr->additional_index()); | 2970 instr->additional_index()); |
| 2989 __ movsd(result, double_load_operand); | 2971 __ movsd(result, double_load_operand); |
| 2990 } | 2972 } |
| 2991 | 2973 |
| 2992 | 2974 |
| 2993 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { | 2975 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) { |
| 2994 HLoadKeyed* hinstr = instr->hydrogen(); | 2976 HLoadKeyed* hinstr = instr->hydrogen(); |
| 2995 Register result = ToRegister(instr->result()); | 2977 Register result = ToRegister(instr->result()); |
| 2996 LOperand* key = instr->key(); | 2978 LOperand* key = instr->key(); |
| 2997 if (!key->IsConstantOperand()) { | |
| 2998 Register key_reg = ToRegister(key); | |
| 2999 // Even though the HLoad/StoreKeyedFastElement instructions force | |
| 3000 // the input representation for the key to be an integer, the input | |
| 3001 // gets replaced during bound check elimination with the index | |
| 3002 // argument to the bounds check, which can be tagged, so that | |
| 3003 // case must be handled here, too. | |
| 3004 if (hinstr->IsDehoisted()) { | |
| 3005 // Sign extend key because it could be a 32 bit negative value | |
| 3006 // and the dehoisted address computation happens in 64 bits | |
| 3007 __ movsxlq(key_reg, key_reg); | |
| 3008 } | |
| 3009 } | |
| 3010 | |
| 3011 bool requires_hole_check = hinstr->RequiresHoleCheck(); | 2979 bool requires_hole_check = hinstr->RequiresHoleCheck(); |
| 3012 int offset = FixedArray::kHeaderSize - kHeapObjectTag; | 2980 int offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| 3013 Representation representation = hinstr->representation(); | 2981 Representation representation = hinstr->representation(); |
| 3014 | 2982 |
| 3015 if (representation.IsInteger32() && | 2983 if (representation.IsInteger32() && |
| 3016 hinstr->elements_kind() == FAST_SMI_ELEMENTS) { | 2984 hinstr->elements_kind() == FAST_SMI_ELEMENTS) { |
| 3017 ASSERT(!requires_hole_check); | 2985 ASSERT(!requires_hole_check); |
| 3018 #ifdef DEBUG | 2986 #ifdef DEBUG |
| 3019 Register scratch = kScratchRegister; | 2987 Register scratch = kScratchRegister; |
| 3020 __ Load(scratch, | 2988 __ Load(scratch, |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4060 } | 4028 } |
| 4061 Condition condition = | 4029 Condition condition = |
| 4062 instr->hydrogen()->allow_equality() ? below : below_equal; | 4030 instr->hydrogen()->allow_equality() ? below : below_equal; |
| 4063 ApplyCheckIf(condition, instr); | 4031 ApplyCheckIf(condition, instr); |
| 4064 } | 4032 } |
| 4065 | 4033 |
| 4066 | 4034 |
| 4067 void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { | 4035 void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) { |
| 4068 ElementsKind elements_kind = instr->elements_kind(); | 4036 ElementsKind elements_kind = instr->elements_kind(); |
| 4069 LOperand* key = instr->key(); | 4037 LOperand* key = instr->key(); |
| 4070 if (!key->IsConstantOperand()) { | |
| 4071 Register key_reg = ToRegister(key); | |
| 4072 // Even though the HLoad/StoreKeyedFastElement instructions force | |
| 4073 // the input representation for the key to be an integer, the input | |
| 4074 // gets replaced during bound check elimination with the index | |
| 4075 // argument to the bounds check, which can be tagged, so that case | |
| 4076 // must be handled here, too. | |
| 4077 if (instr->hydrogen()->IsDehoisted()) { | |
| 4078 // Sign extend key because it could be a 32 bit negative value | |
| 4079 // and the dehoisted address computation happens in 64 bits | |
| 4080 __ movsxlq(key_reg, key_reg); | |
| 4081 } | |
| 4082 } | |
| 4083 int base_offset = instr->is_fixed_typed_array() | 4038 int base_offset = instr->is_fixed_typed_array() |
| 4084 ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag | 4039 ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag |
| 4085 : 0; | 4040 : 0; |
| 4086 Operand operand(BuildFastArrayOperand( | 4041 Operand operand(BuildFastArrayOperand( |
| 4087 instr->elements(), | 4042 instr->elements(), |
| 4088 key, | 4043 key, |
| 4089 elements_kind, | 4044 elements_kind, |
| 4090 base_offset, | 4045 base_offset, |
| 4091 instr->additional_index())); | 4046 instr->additional_index())); |
| 4092 | 4047 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4136 UNREACHABLE(); | 4091 UNREACHABLE(); |
| 4137 break; | 4092 break; |
| 4138 } | 4093 } |
| 4139 } | 4094 } |
| 4140 } | 4095 } |
| 4141 | 4096 |
| 4142 | 4097 |
| 4143 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { | 4098 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) { |
| 4144 XMMRegister value = ToDoubleRegister(instr->value()); | 4099 XMMRegister value = ToDoubleRegister(instr->value()); |
| 4145 LOperand* key = instr->key(); | 4100 LOperand* key = instr->key(); |
| 4146 if (!key->IsConstantOperand()) { | |
| 4147 Register key_reg = ToRegister(key); | |
| 4148 // Even though the HLoad/StoreKeyedFastElement instructions force | |
| 4149 // the input representation for the key to be an integer, the | |
| 4150 // input gets replaced during bound check elimination with the index | |
| 4151 // argument to the bounds check, which can be tagged, so that case | |
| 4152 // must be handled here, too. | |
| 4153 if (instr->hydrogen()->IsDehoisted()) { | |
| 4154 // Sign extend key because it could be a 32 bit negative value | |
| 4155 // and the dehoisted address computation happens in 64 bits | |
| 4156 __ movsxlq(key_reg, key_reg); | |
| 4157 } | |
| 4158 } | |
| 4159 | |
| 4160 if (instr->NeedsCanonicalization()) { | 4101 if (instr->NeedsCanonicalization()) { |
| 4161 Label have_value; | 4102 Label have_value; |
| 4162 | 4103 |
| 4163 __ ucomisd(value, value); | 4104 __ ucomisd(value, value); |
| 4164 __ j(parity_odd, &have_value, Label::kNear); // NaN. | 4105 __ j(parity_odd, &have_value, Label::kNear); // NaN. |
| 4165 | 4106 |
| 4166 __ Set(kScratchRegister, BitCast<uint64_t>( | 4107 __ Set(kScratchRegister, BitCast<uint64_t>( |
| 4167 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); | 4108 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); |
| 4168 __ movq(value, kScratchRegister); | 4109 __ movq(value, kScratchRegister); |
| 4169 | 4110 |
| 4170 __ bind(&have_value); | 4111 __ bind(&have_value); |
| 4171 } | 4112 } |
| 4172 | 4113 |
| 4173 Operand double_store_operand = BuildFastArrayOperand( | 4114 Operand double_store_operand = BuildFastArrayOperand( |
| 4174 instr->elements(), | 4115 instr->elements(), |
| 4175 key, | 4116 key, |
| 4176 FAST_DOUBLE_ELEMENTS, | 4117 FAST_DOUBLE_ELEMENTS, |
| 4177 FixedDoubleArray::kHeaderSize - kHeapObjectTag, | 4118 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| 4178 instr->additional_index()); | 4119 instr->additional_index()); |
| 4179 | 4120 |
| 4180 __ movsd(double_store_operand, value); | 4121 __ movsd(double_store_operand, value); |
| 4181 } | 4122 } |
| 4182 | 4123 |
| 4183 | 4124 |
| 4184 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { | 4125 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) { |
| 4185 HStoreKeyed* hinstr = instr->hydrogen(); | 4126 HStoreKeyed* hinstr = instr->hydrogen(); |
| 4186 LOperand* key = instr->key(); | 4127 LOperand* key = instr->key(); |
| 4187 if (!key->IsConstantOperand()) { | |
| 4188 Register key_reg = ToRegister(key); | |
| 4189 // Even though the HLoad/StoreKeyedFastElement instructions force | |
| 4190 // the input representation for the key to be an integer, the | |
| 4191 // input gets replaced during bound check elimination with the index | |
| 4192 // argument to the bounds check, which can be tagged, so that case | |
| 4193 // must be handled here, too. | |
| 4194 if (hinstr->IsDehoisted()) { | |
| 4195 // Sign extend key because it could be a 32 bit negative value | |
| 4196 // and the dehoisted address computation happens in 64 bits | |
| 4197 __ movsxlq(key_reg, key_reg); | |
| 4198 } | |
| 4199 } | |
| 4200 | |
| 4201 int offset = FixedArray::kHeaderSize - kHeapObjectTag; | 4128 int offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| 4202 Representation representation = hinstr->value()->representation(); | 4129 Representation representation = hinstr->value()->representation(); |
| 4203 | 4130 |
| 4204 if (representation.IsInteger32()) { | 4131 if (representation.IsInteger32()) { |
| 4205 ASSERT(hinstr->store_mode() == STORE_TO_INITIALIZED_ENTRY); | 4132 ASSERT(hinstr->store_mode() == STORE_TO_INITIALIZED_ENTRY); |
| 4206 ASSERT(hinstr->elements_kind() == FAST_SMI_ELEMENTS); | 4133 ASSERT(hinstr->elements_kind() == FAST_SMI_ELEMENTS); |
| 4207 #ifdef DEBUG | 4134 #ifdef DEBUG |
| 4208 Register scratch = kScratchRegister; | 4135 Register scratch = kScratchRegister; |
| 4209 __ Load(scratch, | 4136 __ Load(scratch, |
| 4210 BuildFastArrayOperand(instr->elements(), | 4137 BuildFastArrayOperand(instr->elements(), |
| (...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5578 FixedArray::kHeaderSize - kPointerSize)); | 5505 FixedArray::kHeaderSize - kPointerSize)); |
| 5579 __ bind(&done); | 5506 __ bind(&done); |
| 5580 } | 5507 } |
| 5581 | 5508 |
| 5582 | 5509 |
| 5583 #undef __ | 5510 #undef __ |
| 5584 | 5511 |
| 5585 } } // namespace v8::internal | 5512 } } // namespace v8::internal |
| 5586 | 5513 |
| 5587 #endif // V8_TARGET_ARCH_X64 | 5514 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |