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

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

Issue 7191007: Cleanup: use JumpIf[Not]Smi() whenever we can (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: introduced new macro Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/arm/code-stubs-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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { 612 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) {
613 // ----------- S t a t e ------------- 613 // ----------- S t a t e -------------
614 // -- r0 : number of arguments 614 // -- r0 : number of arguments
615 // -- r1 : constructor function 615 // -- r1 : constructor function
616 // -- lr : return address 616 // -- lr : return address
617 // -- sp[...]: constructor arguments 617 // -- sp[...]: constructor arguments
618 // ----------------------------------- 618 // -----------------------------------
619 619
620 Label non_function_call; 620 Label non_function_call;
621 // Check that the function is not a smi. 621 // Check that the function is not a smi.
622 __ tst(r1, Operand(kSmiTagMask)); 622 __ JumpIfSmi(r1, &non_function_call);
623 __ b(eq, &non_function_call);
624 // Check that the function is a JSFunction. 623 // Check that the function is a JSFunction.
625 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); 624 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE);
626 __ b(ne, &non_function_call); 625 __ b(ne, &non_function_call);
627 626
628 // Jump to the function-specific construct stub. 627 // Jump to the function-specific construct stub.
629 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 628 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
630 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); 629 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset));
631 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); 630 __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag));
632 631
633 // r0: number of arguments 632 // r0: number of arguments
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 ExternalReference::debug_step_in_fp_address(isolate); 667 ExternalReference::debug_step_in_fp_address(isolate);
669 __ mov(r2, Operand(debug_step_in_fp)); 668 __ mov(r2, Operand(debug_step_in_fp));
670 __ ldr(r2, MemOperand(r2)); 669 __ ldr(r2, MemOperand(r2));
671 __ tst(r2, r2); 670 __ tst(r2, r2);
672 __ b(ne, &rt_call); 671 __ b(ne, &rt_call);
673 #endif 672 #endif
674 673
675 // Load the initial map and verify that it is in fact a map. 674 // Load the initial map and verify that it is in fact a map.
676 // r1: constructor function 675 // r1: constructor function
677 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); 676 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset));
678 __ tst(r2, Operand(kSmiTagMask)); 677 __ JumpIfSmi(r2, &rt_call);
679 __ b(eq, &rt_call);
680 __ CompareObjectType(r2, r3, r4, MAP_TYPE); 678 __ CompareObjectType(r2, r3, r4, MAP_TYPE);
681 __ b(ne, &rt_call); 679 __ b(ne, &rt_call);
682 680
683 // Check that the constructor is not constructing a JSFunction (see comments 681 // Check that the constructor is not constructing a JSFunction (see comments
684 // in Runtime_NewObject in runtime.cc). In which case the initial map's 682 // in Runtime_NewObject in runtime.cc). In which case the initial map's
685 // instance type would be JS_FUNCTION_TYPE. 683 // instance type would be JS_FUNCTION_TYPE.
686 // r1: constructor function 684 // r1: constructor function
687 // r2: initial map 685 // r2: initial map
688 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); 686 __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE);
689 __ b(eq, &rt_call); 687 __ b(eq, &rt_call);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 // If the result is an object (in the ECMA sense), we should get rid 937 // If the result is an object (in the ECMA sense), we should get rid
940 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 938 // of the receiver and use the result; see ECMA-262 section 13.2.2-7
941 // on page 74. 939 // on page 74.
942 Label use_receiver, exit; 940 Label use_receiver, exit;
943 941
944 // If the result is a smi, it is *not* an object in the ECMA sense. 942 // If the result is a smi, it is *not* an object in the ECMA sense.
945 // r0: result 943 // r0: result
946 // sp[0]: receiver (newly allocated object) 944 // sp[0]: receiver (newly allocated object)
947 // sp[1]: constructor function 945 // sp[1]: constructor function
948 // sp[2]: number of arguments (smi-tagged) 946 // sp[2]: number of arguments (smi-tagged)
949 __ tst(r0, Operand(kSmiTagMask)); 947 __ JumpIfSmi(r0, &use_receiver);
950 __ b(eq, &use_receiver);
951 948
952 // If the type of the result (stored in its map) is less than 949 // If the type of the result (stored in its map) is less than
953 // FIRST_SPEC_OBJECT_TYPE, it is not an object in the ECMA sense. 950 // FIRST_SPEC_OBJECT_TYPE, it is not an object in the ECMA sense.
954 __ CompareObjectType(r0, r3, r3, FIRST_SPEC_OBJECT_TYPE); 951 __ CompareObjectType(r0, r3, r3, FIRST_SPEC_OBJECT_TYPE);
955 __ b(ge, &exit); 952 __ b(ge, &exit);
956 953
957 // Throw away the result of the constructor invocation and use the 954 // Throw away the result of the constructor invocation and use the
958 // on-stack receiver as the result. 955 // on-stack receiver as the result.
959 __ bind(&use_receiver); 956 __ bind(&use_receiver);
960 __ ldr(r0, MemOperand(sp)); 957 __ ldr(r0, MemOperand(sp));
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 __ push(r2); 1226 __ push(r2);
1230 __ add(r0, r0, Operand(1)); 1227 __ add(r0, r0, Operand(1));
1231 __ bind(&done); 1228 __ bind(&done);
1232 } 1229 }
1233 1230
1234 // 2. Get the function to call (passed as receiver) from the stack, check 1231 // 2. Get the function to call (passed as receiver) from the stack, check
1235 // if it is a function. 1232 // if it is a function.
1236 // r0: actual number of arguments 1233 // r0: actual number of arguments
1237 Label non_function; 1234 Label non_function;
1238 __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); 1235 __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
1239 __ tst(r1, Operand(kSmiTagMask)); 1236 __ JumpIfSmi(r1, &non_function);
1240 __ b(eq, &non_function);
1241 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); 1237 __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE);
1242 __ b(ne, &non_function); 1238 __ b(ne, &non_function);
1243 1239
1244 // 3a. Patch the first argument if necessary when calling a function. 1240 // 3a. Patch the first argument if necessary when calling a function.
1245 // r0: actual number of arguments 1241 // r0: actual number of arguments
1246 // r1: function 1242 // r1: function
1247 Label shift_arguments; 1243 Label shift_arguments;
1248 { Label convert_to_object, use_global_receiver, patch_receiver; 1244 { Label convert_to_object, use_global_receiver, patch_receiver;
1249 // Change context eagerly in case we need the global receiver. 1245 // Change context eagerly in case we need the global receiver.
1250 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); 1246 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
1251 1247
1252 // Do not transform the receiver for strict mode functions. 1248 // Do not transform the receiver for strict mode functions.
1253 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1249 __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1254 __ ldr(r3, FieldMemOperand(r2, SharedFunctionInfo::kCompilerHintsOffset)); 1250 __ ldr(r3, FieldMemOperand(r2, SharedFunctionInfo::kCompilerHintsOffset));
1255 __ tst(r3, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 1251 __ tst(r3, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
1256 kSmiTagSize))); 1252 kSmiTagSize)));
1257 __ b(ne, &shift_arguments); 1253 __ b(ne, &shift_arguments);
1258 1254
1259 // Do not transform the receiver for native (Compilerhints already in r3). 1255 // Do not transform the receiver for native (Compilerhints already in r3).
1260 __ tst(r3, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 1256 __ tst(r3, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
1261 __ b(ne, &shift_arguments); 1257 __ b(ne, &shift_arguments);
1262 1258
1263 // Compute the receiver in non-strict mode. 1259 // Compute the receiver in non-strict mode.
1264 __ add(r2, sp, Operand(r0, LSL, kPointerSizeLog2)); 1260 __ add(r2, sp, Operand(r0, LSL, kPointerSizeLog2));
1265 __ ldr(r2, MemOperand(r2, -kPointerSize)); 1261 __ ldr(r2, MemOperand(r2, -kPointerSize));
1266 // r0: actual number of arguments 1262 // r0: actual number of arguments
1267 // r1: function 1263 // r1: function
1268 // r2: first argument 1264 // r2: first argument
1269 __ tst(r2, Operand(kSmiTagMask)); 1265 __ JumpIfSmi(r2, &convert_to_object);
1270 __ b(eq, &convert_to_object);
1271 1266
1272 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); 1267 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
1273 __ cmp(r2, r3); 1268 __ cmp(r2, r3);
1274 __ b(eq, &use_global_receiver); 1269 __ b(eq, &use_global_receiver);
1275 __ LoadRoot(r3, Heap::kNullValueRootIndex); 1270 __ LoadRoot(r3, Heap::kNullValueRootIndex);
1276 __ cmp(r2, r3); 1271 __ cmp(r2, r3);
1277 __ b(eq, &use_global_receiver); 1272 __ b(eq, &use_global_receiver);
1278 1273
1279 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); 1274 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE);
1280 __ CompareObjectType(r2, r3, r3, FIRST_SPEC_OBJECT_TYPE); 1275 __ CompareObjectType(r2, r3, r3, FIRST_SPEC_OBJECT_TYPE);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 __ ldr(r2, FieldMemOperand(r1, SharedFunctionInfo::kCompilerHintsOffset)); 1433 __ ldr(r2, FieldMemOperand(r1, SharedFunctionInfo::kCompilerHintsOffset));
1439 __ tst(r2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 1434 __ tst(r2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
1440 kSmiTagSize))); 1435 kSmiTagSize)));
1441 __ b(ne, &push_receiver); 1436 __ b(ne, &push_receiver);
1442 1437
1443 // Do not transform the receiver for strict mode functions. 1438 // Do not transform the receiver for strict mode functions.
1444 __ tst(r2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 1439 __ tst(r2, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
1445 __ b(ne, &push_receiver); 1440 __ b(ne, &push_receiver);
1446 1441
1447 // Compute the receiver in non-strict mode. 1442 // Compute the receiver in non-strict mode.
1448 __ tst(r0, Operand(kSmiTagMask)); 1443 __ JumpIfSmi(r0, &call_to_object);
1449 __ b(eq, &call_to_object);
1450 __ LoadRoot(r1, Heap::kNullValueRootIndex); 1444 __ LoadRoot(r1, Heap::kNullValueRootIndex);
1451 __ cmp(r0, r1); 1445 __ cmp(r0, r1);
1452 __ b(eq, &use_global_receiver); 1446 __ b(eq, &use_global_receiver);
1453 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); 1447 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex);
1454 __ cmp(r0, r1); 1448 __ cmp(r0, r1);
1455 __ b(eq, &use_global_receiver); 1449 __ b(eq, &use_global_receiver);
1456 1450
1457 // Check if the receiver is already a JavaScript object. 1451 // Check if the receiver is already a JavaScript object.
1458 // r0: receiver 1452 // r0: receiver
1459 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); 1453 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 __ bind(&dont_adapt_arguments); 1643 __ bind(&dont_adapt_arguments);
1650 __ Jump(r3); 1644 __ Jump(r3);
1651 } 1645 }
1652 1646
1653 1647
1654 #undef __ 1648 #undef __
1655 1649
1656 } } // namespace v8::internal 1650 } } // namespace v8::internal
1657 1651
1658 #endif // V8_TARGET_ARCH_ARM 1652 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698