| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/x87/codegen-x87.h" | 5 #include "src/x87/codegen-x87.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Code generators | 211 // Code generators |
| 212 | 212 |
| 213 #define __ ACCESS_MASM(masm) | 213 #define __ ACCESS_MASM(masm) |
| 214 | 214 |
| 215 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 215 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
| 216 Factory* factory, | 216 Factory* factory, |
| 217 Register string, | 217 Register string, |
| 218 Register index, | 218 Register index, |
| 219 Register result, | 219 Register result, |
| 220 Label* call_runtime) { | 220 Label* call_runtime) { |
| 221 Label indirect_string_loaded; |
| 222 __ bind(&indirect_string_loaded); |
| 223 |
| 221 // Fetch the instance type of the receiver into result register. | 224 // Fetch the instance type of the receiver into result register. |
| 222 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | 225 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); |
| 223 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 226 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
| 224 | 227 |
| 225 // We need special handling for indirect strings. | 228 // We need special handling for indirect strings. |
| 226 Label check_sequential; | 229 Label check_sequential; |
| 227 __ test(result, Immediate(kIsIndirectStringMask)); | 230 __ test(result, Immediate(kIsIndirectStringMask)); |
| 228 __ j(zero, &check_sequential, Label::kNear); | 231 __ j(zero, &check_sequential, Label::kNear); |
| 229 | 232 |
| 230 // Dispatch on the indirect string shape: slice or cons. | 233 // Dispatch on the indirect string shape: slice or cons. |
| 231 Label cons_string; | 234 Label cons_string, thin_string; |
| 232 __ test(result, Immediate(kSlicedNotConsMask)); | 235 __ and_(result, Immediate(kStringRepresentationMask)); |
| 233 __ j(zero, &cons_string, Label::kNear); | 236 __ cmp(result, Immediate(kConsStringTag)); |
| 237 __ j(equal, &cons_string, Label::kNear); |
| 238 __ cmp(result, Immediate(kThinStringTag)); |
| 239 __ j(equal, &thin_string, Label::kNear); |
| 234 | 240 |
| 235 // Handle slices. | 241 // Handle slices. |
| 236 Label indirect_string_loaded; | |
| 237 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); | 242 __ mov(result, FieldOperand(string, SlicedString::kOffsetOffset)); |
| 238 __ SmiUntag(result); | 243 __ SmiUntag(result); |
| 239 __ add(index, result); | 244 __ add(index, result); |
| 240 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); | 245 __ mov(string, FieldOperand(string, SlicedString::kParentOffset)); |
| 241 __ jmp(&indirect_string_loaded, Label::kNear); | 246 __ jmp(&indirect_string_loaded); |
| 247 |
| 248 // Handle thin strings. |
| 249 __ bind(&thin_string); |
| 250 __ mov(string, FieldOperand(string, ThinString::kActualOffset)); |
| 251 __ jmp(&indirect_string_loaded); |
| 242 | 252 |
| 243 // Handle cons strings. | 253 // Handle cons strings. |
| 244 // Check whether the right hand side is the empty string (i.e. if | 254 // Check whether the right hand side is the empty string (i.e. if |
| 245 // this is really a flat string in a cons string). If that is not | 255 // this is really a flat string in a cons string). If that is not |
| 246 // the case we would rather go to the runtime system now to flatten | 256 // the case we would rather go to the runtime system now to flatten |
| 247 // the string. | 257 // the string. |
| 248 __ bind(&cons_string); | 258 __ bind(&cons_string); |
| 249 __ cmp(FieldOperand(string, ConsString::kSecondOffset), | 259 __ cmp(FieldOperand(string, ConsString::kSecondOffset), |
| 250 Immediate(factory->empty_string())); | 260 Immediate(factory->empty_string())); |
| 251 __ j(not_equal, call_runtime); | 261 __ j(not_equal, call_runtime); |
| 252 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); | 262 __ mov(string, FieldOperand(string, ConsString::kFirstOffset)); |
| 253 | 263 __ jmp(&indirect_string_loaded); |
| 254 __ bind(&indirect_string_loaded); | |
| 255 __ mov(result, FieldOperand(string, HeapObject::kMapOffset)); | |
| 256 __ movzx_b(result, FieldOperand(result, Map::kInstanceTypeOffset)); | |
| 257 | 264 |
| 258 // Distinguish sequential and external strings. Only these two string | 265 // Distinguish sequential and external strings. Only these two string |
| 259 // representations can reach here (slices and flat cons strings have been | 266 // representations can reach here (slices and flat cons strings have been |
| 260 // reduced to the underlying sequential or external string). | 267 // reduced to the underlying sequential or external string). |
| 261 Label seq_string; | 268 Label seq_string; |
| 262 __ bind(&check_sequential); | 269 __ bind(&check_sequential); |
| 263 STATIC_ASSERT(kSeqStringTag == 0); | 270 STATIC_ASSERT(kSeqStringTag == 0); |
| 264 __ test(result, Immediate(kStringRepresentationMask)); | 271 __ test(result, Immediate(kStringRepresentationMask)); |
| 265 __ j(zero, &seq_string, Label::kNear); | 272 __ j(zero, &seq_string, Label::kNear); |
| 266 | 273 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 CodePatcher patcher(isolate, sequence, young_length); | 372 CodePatcher patcher(isolate, sequence, young_length); |
| 366 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 373 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
| 367 } | 374 } |
| 368 } | 375 } |
| 369 | 376 |
| 370 | 377 |
| 371 } // namespace internal | 378 } // namespace internal |
| 372 } // namespace v8 | 379 } // namespace v8 |
| 373 | 380 |
| 374 #endif // V8_TARGET_ARCH_X87 | 381 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |