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

Side by Side Diff: src/mips/builtins-mips.cc

Issue 8428004: MIPS: Cleanup: use JumpIf[Not]Smi() whenever we can (Closed)
Patch Set: Fixed typo, rebased to r9884 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
« no previous file with comments | « no previous file | src/mips/code-stubs-mips.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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { 621 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
622 // ----------- S t a t e ------------- 622 // ----------- S t a t e -------------
623 // -- a0 : number of arguments 623 // -- a0 : number of arguments
624 // -- a1 : constructor function 624 // -- a1 : constructor function
625 // -- ra : return address 625 // -- ra : return address
626 // -- sp[...]: constructor arguments 626 // -- sp[...]: constructor arguments
627 // ----------------------------------- 627 // -----------------------------------
628 628
629 Label slow, non_function_call; 629 Label slow, non_function_call;
630 // Check that the function is not a smi. 630 // Check that the function is not a smi.
631 __ And(t0, a1, Operand(kSmiTagMask)); 631 __ JumpIfSmi(a1, &non_function_call);
632 __ Branch(&non_function_call, eq, t0, Operand(zero_reg));
633 // Check that the function is a JSFunction. 632 // Check that the function is a JSFunction.
634 __ GetObjectType(a1, a2, a2); 633 __ GetObjectType(a1, a2, a2);
635 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE)); 634 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE));
636 635
637 // Jump to the function-specific construct stub. 636 // Jump to the function-specific construct stub.
638 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 637 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
639 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset)); 638 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset));
640 __ Addu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); 639 __ Addu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag));
641 __ Jump(t9); 640 __ Jump(t9);
642 641
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 ExternalReference debug_step_in_fp = 697 ExternalReference debug_step_in_fp =
699 ExternalReference::debug_step_in_fp_address(isolate); 698 ExternalReference::debug_step_in_fp_address(isolate);
700 __ li(a2, Operand(debug_step_in_fp)); 699 __ li(a2, Operand(debug_step_in_fp));
701 __ lw(a2, MemOperand(a2)); 700 __ lw(a2, MemOperand(a2));
702 __ Branch(&rt_call, ne, a2, Operand(zero_reg)); 701 __ Branch(&rt_call, ne, a2, Operand(zero_reg));
703 #endif 702 #endif
704 703
705 // Load the initial map and verify that it is in fact a map. 704 // Load the initial map and verify that it is in fact a map.
706 // a1: constructor function 705 // a1: constructor function
707 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); 706 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
708 __ And(t0, a2, Operand(kSmiTagMask)); 707 __ JumpIfSmi(a2, &rt_call);
709 __ Branch(&rt_call, eq, t0, Operand(zero_reg));
710 __ GetObjectType(a2, a3, t4); 708 __ GetObjectType(a2, a3, t4);
711 __ Branch(&rt_call, ne, t4, Operand(MAP_TYPE)); 709 __ Branch(&rt_call, ne, t4, Operand(MAP_TYPE));
712 710
713 // Check that the constructor is not constructing a JSFunction (see 711 // Check that the constructor is not constructing a JSFunction (see
714 // comments in Runtime_NewObject in runtime.cc). In which case the 712 // comments in Runtime_NewObject in runtime.cc). In which case the
715 // initial map's instance type would be JS_FUNCTION_TYPE. 713 // initial map's instance type would be JS_FUNCTION_TYPE.
716 // a1: constructor function 714 // a1: constructor function
717 // a2: initial map 715 // a2: initial map
718 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset)); 716 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset));
719 __ Branch(&rt_call, eq, a3, Operand(JS_FUNCTION_TYPE)); 717 __ Branch(&rt_call, eq, a3, Operand(JS_FUNCTION_TYPE));
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // If the result is an object (in the ECMA sense), we should get rid 975 // If the result is an object (in the ECMA sense), we should get rid
978 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 976 // of the receiver and use the result; see ECMA-262 section 13.2.2-7
979 // on page 74. 977 // on page 74.
980 Label use_receiver, exit; 978 Label use_receiver, exit;
981 979
982 // If the result is a smi, it is *not* an object in the ECMA sense. 980 // If the result is a smi, it is *not* an object in the ECMA sense.
983 // v0: result 981 // v0: result
984 // sp[0]: receiver (newly allocated object) 982 // sp[0]: receiver (newly allocated object)
985 // sp[1]: constructor function 983 // sp[1]: constructor function
986 // sp[2]: number of arguments (smi-tagged) 984 // sp[2]: number of arguments (smi-tagged)
987 __ And(t0, v0, Operand(kSmiTagMask)); 985 __ JumpIfSmi(v0, &use_receiver);
988 __ Branch(&use_receiver, eq, t0, Operand(zero_reg));
989 986
990 // If the type of the result (stored in its map) is less than 987 // If the type of the result (stored in its map) is less than
991 // FIRST_SPEC_OBJECT_TYPE, it is not an object in the ECMA sense. 988 // FIRST_SPEC_OBJECT_TYPE, it is not an object in the ECMA sense.
992 __ GetObjectType(v0, a3, a3); 989 __ GetObjectType(v0, a3, a3);
993 __ Branch(&exit, greater_equal, a3, Operand(FIRST_SPEC_OBJECT_TYPE)); 990 __ Branch(&exit, greater_equal, a3, Operand(FIRST_SPEC_OBJECT_TYPE));
994 991
995 // Throw away the result of the constructor invocation and use the 992 // Throw away the result of the constructor invocation and use the
996 // on-stack receiver as the result. 993 // on-stack receiver as the result.
997 __ bind(&use_receiver); 994 __ bind(&use_receiver);
998 __ lw(v0, MemOperand(sp)); 995 __ lw(v0, MemOperand(sp));
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 __ bind(&done); 1274 __ bind(&done);
1278 } 1275 }
1279 1276
1280 // 2. Get the function to call (passed as receiver) from the stack, check 1277 // 2. Get the function to call (passed as receiver) from the stack, check
1281 // if it is a function. 1278 // if it is a function.
1282 // a0: actual number of arguments 1279 // a0: actual number of arguments
1283 Label slow, non_function; 1280 Label slow, non_function;
1284 __ sll(at, a0, kPointerSizeLog2); 1281 __ sll(at, a0, kPointerSizeLog2);
1285 __ addu(at, sp, at); 1282 __ addu(at, sp, at);
1286 __ lw(a1, MemOperand(at)); 1283 __ lw(a1, MemOperand(at));
1287 __ And(at, a1, Operand(kSmiTagMask)); 1284 __ JumpIfSmi(a1, &non_function);
1288 __ Branch(&non_function, eq, at, Operand(zero_reg));
1289 __ GetObjectType(a1, a2, a2); 1285 __ GetObjectType(a1, a2, a2);
1290 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE)); 1286 __ Branch(&slow, ne, a2, Operand(JS_FUNCTION_TYPE));
1291 1287
1292 // 3a. Patch the first argument if necessary when calling a function. 1288 // 3a. Patch the first argument if necessary when calling a function.
1293 // a0: actual number of arguments 1289 // a0: actual number of arguments
1294 // a1: function 1290 // a1: function
1295 Label shift_arguments; 1291 Label shift_arguments;
1296 __ li(t0, Operand(0, RelocInfo::NONE)); // Indicate regular JS_FUNCTION. 1292 __ li(t0, Operand(0, RelocInfo::NONE)); // Indicate regular JS_FUNCTION.
1297 { Label convert_to_object, use_global_receiver, patch_receiver; 1293 { Label convert_to_object, use_global_receiver, patch_receiver;
1298 // Change context eagerly in case we need the global receiver. 1294 // Change context eagerly in case we need the global receiver.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset)); 1513 __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kCompilerHintsOffset));
1518 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 1514 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
1519 kSmiTagSize))); 1515 kSmiTagSize)));
1520 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); 1516 __ Branch(&push_receiver, ne, t3, Operand(zero_reg));
1521 1517
1522 // Do not transform the receiver for native (Compilerhints already in a2). 1518 // Do not transform the receiver for native (Compilerhints already in a2).
1523 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 1519 __ And(t3, a2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
1524 __ Branch(&push_receiver, ne, t3, Operand(zero_reg)); 1520 __ Branch(&push_receiver, ne, t3, Operand(zero_reg));
1525 1521
1526 // Compute the receiver in non-strict mode. 1522 // Compute the receiver in non-strict mode.
1527 __ And(t3, a0, Operand(kSmiTagMask)); 1523 __ JumpIfSmi(a0, &call_to_object);
1528 __ Branch(&call_to_object, eq, t3, Operand(zero_reg));
1529 __ LoadRoot(a1, Heap::kNullValueRootIndex); 1524 __ LoadRoot(a1, Heap::kNullValueRootIndex);
1530 __ Branch(&use_global_receiver, eq, a0, Operand(a1)); 1525 __ Branch(&use_global_receiver, eq, a0, Operand(a1));
1531 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); 1526 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
1532 __ Branch(&use_global_receiver, eq, a0, Operand(a2)); 1527 __ Branch(&use_global_receiver, eq, a0, Operand(a2));
1533 1528
1534 // Check if the receiver is already a JavaScript object. 1529 // Check if the receiver is already a JavaScript object.
1535 // a0: receiver 1530 // a0: receiver
1536 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); 1531 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE);
1537 __ GetObjectType(a0, a1, a1); 1532 __ GetObjectType(a0, a1, a1);
1538 __ Branch(&push_receiver, ge, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); 1533 __ Branch(&push_receiver, ge, a1, Operand(FIRST_SPEC_OBJECT_TYPE));
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 __ bind(&dont_adapt_arguments); 1751 __ bind(&dont_adapt_arguments);
1757 __ Jump(a3); 1752 __ Jump(a3);
1758 } 1753 }
1759 1754
1760 1755
1761 #undef __ 1756 #undef __
1762 1757
1763 } } // namespace v8::internal 1758 } } // namespace v8::internal
1764 1759
1765 #endif // V8_TARGET_ARCH_MIPS 1760 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698