| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // Check that the object is a JS array. | 335 // Check that the object is a JS array. |
| 336 __ GetObjectType(receiver, scratch, scratch); | 336 __ GetObjectType(receiver, scratch, scratch); |
| 337 __ Branch(miss_label, ne, scratch, Operand(JS_ARRAY_TYPE)); | 337 __ Branch(miss_label, ne, scratch, Operand(JS_ARRAY_TYPE)); |
| 338 | 338 |
| 339 // Load length directly from the JS array. | 339 // Load length directly from the JS array. |
| 340 __ Ret(USE_DELAY_SLOT); | 340 __ Ret(USE_DELAY_SLOT); |
| 341 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); | 341 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 | 344 |
| 345 // Generate code to check if an object is a string. If the object is a | |
| 346 // heap object, its map's instance type is left in the scratch1 register. | |
| 347 // If this is not needed, scratch1 and scratch2 may be the same register. | |
| 348 static void GenerateStringCheck(MacroAssembler* masm, | |
| 349 Register receiver, | |
| 350 Register scratch1, | |
| 351 Register scratch2, | |
| 352 Label* smi, | |
| 353 Label* non_string_object) { | |
| 354 // Check that the receiver isn't a smi. | |
| 355 __ JumpIfSmi(receiver, smi, t0); | |
| 356 | |
| 357 // Check that the object is a string. | |
| 358 __ lw(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
| 359 __ lbu(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | |
| 360 __ And(scratch2, scratch1, Operand(kIsNotStringMask)); | |
| 361 // The cast is to resolve the overload for the argument of 0x0. | |
| 362 __ Branch(non_string_object, | |
| 363 ne, | |
| 364 scratch2, | |
| 365 Operand(static_cast<int32_t>(kStringTag))); | |
| 366 } | |
| 367 | |
| 368 | |
| 369 // Generate code to load the length from a string object and return the length. | |
| 370 // If the receiver object is not a string or a wrapped string object the | |
| 371 // execution continues at the miss label. The register containing the | |
| 372 // receiver is potentially clobbered. | |
| 373 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | |
| 374 Register receiver, | |
| 375 Register scratch1, | |
| 376 Register scratch2, | |
| 377 Label* miss) { | |
| 378 Label check_wrapper; | |
| 379 | |
| 380 // Check if the object is a string leaving the instance type in the | |
| 381 // scratch1 register. | |
| 382 GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, &check_wrapper); | |
| 383 | |
| 384 // Load length directly from the string. | |
| 385 __ Ret(USE_DELAY_SLOT); | |
| 386 __ lw(v0, FieldMemOperand(receiver, String::kLengthOffset)); | |
| 387 | |
| 388 // Check if the object is a JSValue wrapper. | |
| 389 __ bind(&check_wrapper); | |
| 390 __ Branch(miss, ne, scratch1, Operand(JS_VALUE_TYPE)); | |
| 391 | |
| 392 // Unwrap the value and check if the wrapped value is a string. | |
| 393 __ lw(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset)); | |
| 394 GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss); | |
| 395 __ Ret(USE_DELAY_SLOT); | |
| 396 __ lw(v0, FieldMemOperand(scratch1, String::kLengthOffset)); | |
| 397 } | |
| 398 | |
| 399 | |
| 400 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, | 345 void StubCompiler::GenerateLoadFunctionPrototype(MacroAssembler* masm, |
| 401 Register receiver, | 346 Register receiver, |
| 402 Register scratch1, | 347 Register scratch1, |
| 403 Register scratch2, | 348 Register scratch2, |
| 404 Label* miss_label) { | 349 Label* miss_label) { |
| 405 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 350 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
| 406 __ Ret(USE_DELAY_SLOT); | 351 __ Ret(USE_DELAY_SLOT); |
| 407 __ mov(v0, scratch1); | 352 __ mov(v0, scratch1); |
| 408 } | 353 } |
| 409 | 354 |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 // ----------------------------------- | 1498 // ----------------------------------- |
| 1554 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1499 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1555 } | 1500 } |
| 1556 | 1501 |
| 1557 | 1502 |
| 1558 #undef __ | 1503 #undef __ |
| 1559 | 1504 |
| 1560 } } // namespace v8::internal | 1505 } } // namespace v8::internal |
| 1561 | 1506 |
| 1562 #endif // V8_TARGET_ARCH_MIPS | 1507 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |