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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // Check that the object is a JS array. | 344 // Check that the object is a JS array. |
345 __ CompareObjectType(receiver, scratch, scratch, JS_ARRAY_TYPE); | 345 __ CompareObjectType(receiver, scratch, scratch, JS_ARRAY_TYPE); |
346 __ b(ne, miss_label); | 346 __ b(ne, miss_label); |
347 | 347 |
348 // Load length directly from the JS array. | 348 // Load length directly from the JS array. |
349 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 349 __ ldr(r0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
350 __ Ret(); | 350 __ Ret(); |
351 } | 351 } |
352 | 352 |
353 | 353 |
354 // Generate code to check if an object is a string. If the object is a | |
355 // heap object, its map's instance type is left in the scratch1 register. | |
356 // If this is not needed, scratch1 and scratch2 may be the same register. | |
357 static void GenerateStringCheck(MacroAssembler* masm, | |
358 Register receiver, | |
359 Register scratch1, | |
360 Register scratch2, | |
361 Label* smi, | |
362 Label* non_string_object) { | |
363 // Check that the receiver isn't a smi. | |
364 __ JumpIfSmi(receiver, smi); | |
365 | |
366 // Check that the object is a string. | |
367 __ ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
368 __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | |
369 __ and_(scratch2, scratch1, Operand(kIsNotStringMask)); | |
370 // The cast is to resolve the overload for the argument of 0x0. | |
371 __ cmp(scratch2, Operand(static_cast<int32_t>(kStringTag))); | |
372 __ b(ne, non_string_object); | |
373 } | |
374 | |
375 | |
376 // Generate code to load the length from a string object and return the length. | |
377 // If the receiver object is not a string or a wrapped string object the | |
378 // execution continues at the miss label. The register containing the | |
379 // receiver is potentially clobbered. | |
380 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
381 Register receiver, | |
382 Register scratch1, | |
383 Register scratch2, | |
384 Label* miss) { | |
385 Label check_wrapper; | |
386 | |
387 // Check if the object is a string leaving the instance type in the | |
388 // scratch1 register. | |
389 GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, &check_wrapper); | |
390 | |
391 // Load length directly from the string. | |
392 __ ldr(r0, FieldMemOperand(receiver, String::kLengthOffset)); | |
393 __ Ret(); | |
394 | |
395 // Check if the object is a JSValue wrapper. | |
396 __ bind(&check_wrapper); | |
397 __ cmp(scratch1, Operand(JS_VALUE_TYPE)); | |
398 __ b(ne, miss); | |
399 | |
400 // Unwrap the value and check if the wrapped value is a string. | |
401 __ ldr(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); | |
402 GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss); | |
403 __ ldr(r0, FieldMemOperand(scratch1, String::kLengthOffset)); | |
404 __ Ret(); | |
405 } | |
406 | |
407 | |
408 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 354 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
409 Register receiver, | 355 Register receiver, |
410 Register scratch1, | 356 Register scratch1, |
411 Register scratch2, | 357 Register scratch2, |
412 Label* miss_label) { | 358 Label* miss_label) { |
413 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 359 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
414 __ mov(r0, scratch1); | 360 __ mov(r0, scratch1); |
415 __ Ret(); | 361 __ Ret(); |
416 } | 362 } |
417 | 363 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 // ----------------------------------- | 1511 // ----------------------------------- |
1566 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1512 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
1567 } | 1513 } |
1568 | 1514 |
1569 | 1515 |
1570 #undef __ | 1516 #undef __ |
1571 | 1517 |
1572 } } // namespace v8::internal | 1518 } } // namespace v8::internal |
1573 | 1519 |
1574 #endif // V8_TARGET_ARCH_ARM | 1520 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |