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

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

Issue 8596006: Port r10023 to ARM (Add pointer cache field to external string). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/arm/lithium-codegen-arm.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 JSObject::kElementsOffset, 295 JSObject::kElementsOffset,
296 r6, 296 r6,
297 r9, 297 r9,
298 kLRHasBeenSaved, 298 kLRHasBeenSaved,
299 kDontSaveFPRegs, 299 kDontSaveFPRegs,
300 EMIT_REMEMBERED_SET, 300 EMIT_REMEMBERED_SET,
301 OMIT_SMI_CHECK); 301 OMIT_SMI_CHECK);
302 __ pop(lr); 302 __ pop(lr);
303 } 303 }
304 304
305
306 void StringCharLoadGenerator::Generate(MacroAssembler* masm,
307 Register string,
308 Register index,
309 Register result,
310 Label* call_runtime) {
311 // Fetch the instance type of the receiver into result register.
312 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
313 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
314
315 // We need special handling for indirect strings.
316 Label check_sequential;
317 __ tst(result, Operand(kIsIndirectStringMask));
318 __ b(eq, &check_sequential);
319
320 // Dispatch on the indirect string shape: slice or cons.
321 Label cons_string;
322 __ tst(result, Operand(kSlicedNotConsMask));
323 __ b(eq, &cons_string);
324
325 // Handle slices.
326 Label indirect_string_loaded;
327 __ ldr(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
328 __ add(index, index, Operand(result, ASR, kSmiTagSize));
329 __ ldr(string, FieldMemOperand(string, SlicedString::kParentOffset));
330 __ jmp(&indirect_string_loaded);
331
332 // Handle external strings.
333 Label external_string, ascii_external, done;
334 __ bind(&external_string);
335 if (FLAG_debug_code) {
336 // Assert that we do not have a cons or slice (indirect strings) here.
337 // Sequential strings have already been ruled out.
338 __ tst(result, Operand(kIsIndirectStringMask));
339 __ Assert(eq, "external string expected, but not found");
340 }
341 __ ldr(result, FieldMemOperand(string, ExternalString::kResourceDataOffset));
342 // Assert that the data pointer cache is valid.
343 __ tst(result, Operand(result));
344 __ b(eq, call_runtime);
345 Register scratch = string;
346 __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset));
347 __ ldr(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
348 STATIC_ASSERT(kTwoByteStringTag == 0);
349 __ tst(scratch, Operand(kStringEncodingMask));
350 __ b(ne, &ascii_external);
351 // Two-byte string.
352 __ ldrh(result, MemOperand(result, index, LSL, 1));
353 __ jmp(&done);
354
355 __ bind(&ascii_external);
356 // Ascii string.
357 __ ldrb(result, MemOperand(result, index));
358 __ jmp(&done);
359
360 // Handle conses.
361 // Check whether the right hand side is the empty string (i.e. if
362 // this is really a flat string in a cons string). If that is not
363 // the case we would rather go to the runtime system now to flatten
364 // the string.
365 __ bind(&cons_string);
366 __ ldr(result, FieldMemOperand(string, ConsString::kSecondOffset));
367 __ LoadRoot(ip, Heap::kEmptyStringRootIndex);
368 __ cmp(result, ip);
369 __ b(ne, call_runtime);
370 // Get the first of the two strings and load its instance type.
371 __ ldr(string, FieldMemOperand(string, ConsString::kFirstOffset));
372
373 __ bind(&indirect_string_loaded);
374 __ ldr(result, FieldMemOperand(string, HeapObject::kMapOffset));
375 __ ldrb(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
376
377 // Check whether the string is sequential. The only non-sequential
378 // shapes we support have just been unwrapped above.
379 // Note that if the original string is a cons or slice with an external
380 // string as underlying string, we pass that unpacked underlying string with
381 // the adjusted index to the runtime function.
382 __ bind(&check_sequential);
383 STATIC_ASSERT(kSeqStringTag == 0);
384 __ tst(result, Operand(kStringRepresentationMask));
385 __ b(ne, &external_string);
386
387 // Dispatch on the encoding: ASCII or two-byte.
388 Label ascii_string;
389 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
390 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
391 __ tst(result, Operand(kStringEncodingMask));
392 __ b(ne, &ascii_string);
393
394 // Two-byte string.
395 // Load the two-byte character code into the result register.
396 __ add(result,
397 string,
398 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
399 __ ldrh(result, MemOperand(result, index, LSL, 1));
400 __ jmp(&done);
401
402 // ASCII string.
403 // Load the byte into the result register.
404 __ bind(&ascii_string);
405 __ add(result,
406 string,
407 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag));
408 __ ldrb(result, MemOperand(result, index));
409
410 __ bind(&done);
411 }
412
305 #undef __ 413 #undef __
306 414
307 } } // namespace v8::internal 415 } } // namespace v8::internal
308 416
309 #endif // V8_TARGET_ARCH_ARM 417 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/codegen-arm.h ('k') | src/arm/lithium-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698