Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: src/arm/codegen-arm.cc

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: rebased Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/arm/codegen-arm.h" 5 #include "src/arm/codegen-arm.h"
6 6
7 #if V8_TARGET_ARCH_ARM 7 #if V8_TARGET_ARCH_ARM
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // ------------------------------------------------------------------------- 315 // -------------------------------------------------------------------------
316 // Code generators 316 // Code generators
317 317
318 #define __ ACCESS_MASM(masm) 318 #define __ ACCESS_MASM(masm)
319 319
320 void StringCharLoadGenerator::Generate(MacroAssembler* masm, 320 void StringCharLoadGenerator::Generate(MacroAssembler* masm,
321 Register string, 321 Register string,
322 Register index, 322 Register index,
323 Register result, 323 Register result,
324 Label* call_runtime) { 324 Label* call_runtime) {
325 Label indirect_string_loaded;
326 __ bind(&indirect_string_loaded);
327
325 // Fetch the instance type of the receiver into result register. 328 // Fetch the instance type of the receiver into result register.
326 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset)); 329 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
327 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 330 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
328 331
329 // We need special handling for indirect strings. 332 // We need special handling for indirect strings.
330 Label check_sequential; 333 Label check_sequential;
331 __ tst(result, Operand(kIsIndirectStringMask)); 334 __ tst(result, Operand(kIsIndirectStringMask));
332 __ b(eq, &check_sequential); 335 __ b(eq, &check_sequential);
333 336
334 // Dispatch on the indirect string shape: slice or cons. 337 // Dispatch on the indirect string shape: slice or cons.
335 Label cons_string; 338 Label cons_string, thin_string;
336 __ tst(result, Operand(kSlicedNotConsMask)); 339 __ and_(result, result, Operand(kStringRepresentationMask));
340 __ cmp(result, Operand(kConsStringTag));
337 __ b(eq, &cons_string); 341 __ b(eq, &cons_string);
342 __ cmp(result, Operand(kThinStringTag));
343 __ b(eq, &thin_string);
338 344
339 // Handle slices. 345 // Handle slices.
340 Label indirect_string_loaded;
341 __ ldr(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); 346 __ ldr(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
342 __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset)); 347 __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
343 __ add(index, index, Operand::SmiUntag(result)); 348 __ add(index, index, Operand::SmiUntag(result));
344 __ jmp(&indirect_string_loaded); 349 __ jmp(&indirect_string_loaded);
345 350
351 // Handle thin strings.
352 __ bind(&thin_string);
353 __ ldr(string, FieldMemOperand(string, ThinString::kActualOffset));
354 __ jmp(&indirect_string_loaded);
355
346 // Handle cons strings. 356 // Handle cons strings.
347 // Check whether the right hand side is the empty string (i.e. if 357 // Check whether the right hand side is the empty string (i.e. if
348 // this is really a flat string in a cons string). If that is not 358 // this is really a flat string in a cons string). If that is not
349 // the case we would rather go to the runtime system now to flatten 359 // the case we would rather go to the runtime system now to flatten
350 // the string. 360 // the string.
351 __ bind(&cons_string); 361 __ bind(&cons_string);
352 __ ldr(result, FieldMemOperand(string, ConsString::kSecondOffset)); 362 __ ldr(result, FieldMemOperand(string, ConsString::kSecondOffset));
353 __ CompareRoot(result, Heap::kempty_stringRootIndex); 363 __ CompareRoot(result, Heap::kempty_stringRootIndex);
354 __ b(ne, call_runtime); 364 __ b(ne, call_runtime);
355 // Get the first of the two strings and load its instance type. 365 // Get the first of the two strings and load its instance type.
356 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset)); 366 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset));
357 367 __ jmp(&indirect_string_loaded);
358 __ bind(&indirect_string_loaded);
359 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
360 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
361 368
362 // Distinguish sequential and external strings. Only these two string 369 // Distinguish sequential and external strings. Only these two string
363 // representations can reach here (slices and flat cons strings have been 370 // representations can reach here (slices and flat cons strings have been
364 // reduced to the underlying sequential or external string). 371 // reduced to the underlying sequential or external string).
365 Label external_string, check_encoding; 372 Label external_string, check_encoding;
366 __ bind(&check_sequential); 373 __ bind(&check_sequential);
367 STATIC_ASSERT(kSeqStringTag == 0); 374 STATIC_ASSERT(kSeqStringTag == 0);
368 __ tst(result, Operand(kStringRepresentationMask)); 375 __ tst(result, Operand(kStringRepresentationMask));
369 __ b(ne, &external_string); 376 __ b(ne, &external_string);
370 377
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 patcher.masm()->add(r0, pc, Operand(-8)); 469 patcher.masm()->add(r0, pc, Operand(-8));
463 patcher.masm()->ldr(pc, MemOperand(pc, -4)); 470 patcher.masm()->ldr(pc, MemOperand(pc, -4));
464 patcher.masm()->emit_code_stub_address(stub); 471 patcher.masm()->emit_code_stub_address(stub);
465 } 472 }
466 } 473 }
467 474
468 } // namespace internal 475 } // namespace internal
469 } // namespace v8 476 } // namespace v8
470 477
471 #endif // V8_TARGET_ARCH_ARM 478 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698