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

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

Issue 7776010: Convert a bunch of ASSERTs to STATIC_ASSERTs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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 | « src/arm/stub-cache-arm.cc ('k') | src/ia32/full-codegen-ia32.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // on-stack receiver as the result. 366 // on-stack receiver as the result.
367 __ bind(&use_receiver); 367 __ bind(&use_receiver);
368 __ mov(eax, Operand(esp, 0)); 368 __ mov(eax, Operand(esp, 0));
369 369
370 // Restore the arguments count and leave the construct frame. 370 // Restore the arguments count and leave the construct frame.
371 __ bind(&exit); 371 __ bind(&exit);
372 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count 372 __ mov(ebx, Operand(esp, kPointerSize)); // get arguments count
373 __ LeaveConstructFrame(); 373 __ LeaveConstructFrame();
374 374
375 // Remove caller arguments from the stack and return. 375 // Remove caller arguments from the stack and return.
376 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 376 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
377 __ pop(ecx); 377 __ pop(ecx);
378 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver 378 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver
379 __ push(ecx); 379 __ push(ecx);
380 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); 380 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1);
381 __ ret(0); 381 __ ret(0);
382 } 382 }
383 383
384 384
385 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) { 385 void Builtins::Generate_JSConstructStubCountdown(MacroAssembler* masm) {
386 Generate_JSConstructStubHelper(masm, false, true); 386 Generate_JSConstructStubHelper(masm, false, true);
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 // scratch1: elements array 916 // scratch1: elements array
917 // scratch2: start of next object 917 // scratch2: start of next object
918 __ mov(FieldOperand(scratch1, FixedArray::kMapOffset), 918 __ mov(FieldOperand(scratch1, FixedArray::kMapOffset),
919 factory->fixed_array_map()); 919 factory->fixed_array_map());
920 __ mov(FieldOperand(scratch1, FixedArray::kLengthOffset), 920 __ mov(FieldOperand(scratch1, FixedArray::kLengthOffset),
921 Immediate(Smi::FromInt(initial_capacity))); 921 Immediate(Smi::FromInt(initial_capacity)));
922 922
923 // Fill the FixedArray with the hole value. Inline the code if short. 923 // Fill the FixedArray with the hole value. Inline the code if short.
924 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed. 924 // Reconsider loop unfolding if kPreallocatedArrayElements gets changed.
925 static const int kLoopUnfoldLimit = 4; 925 static const int kLoopUnfoldLimit = 4;
926 ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit); 926 STATIC_ASSERT(kPreallocatedArrayElements <= kLoopUnfoldLimit);
927 if (initial_capacity <= kLoopUnfoldLimit) { 927 if (initial_capacity <= kLoopUnfoldLimit) {
928 // Use a scratch register here to have only one reloc info when unfolding 928 // Use a scratch register here to have only one reloc info when unfolding
929 // the loop. 929 // the loop.
930 __ mov(scratch3, factory->the_hole_value()); 930 __ mov(scratch3, factory->the_hole_value());
931 for (int i = 0; i < initial_capacity; i++) { 931 for (int i = 0; i < initial_capacity; i++) {
932 __ mov(FieldOperand(scratch1, 932 __ mov(FieldOperand(scratch1,
933 FixedArray::kHeaderSize + i * kPointerSize), 933 FixedArray::kHeaderSize + i * kPointerSize),
934 scratch3); 934 scratch3);
935 } 935 }
936 } else { 936 } else {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count 968 ASSERT(!fill_with_hole || array_size.is(ecx)); // rep stos count
969 ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax 969 ASSERT(!fill_with_hole || !result.is(eax)); // result is never eax
970 970
971 // Load the initial map from the array function. 971 // Load the initial map from the array function.
972 __ mov(elements_array, 972 __ mov(elements_array,
973 FieldOperand(array_function, 973 FieldOperand(array_function,
974 JSFunction::kPrototypeOrInitialMapOffset)); 974 JSFunction::kPrototypeOrInitialMapOffset));
975 975
976 // Allocate the JSArray object together with space for a FixedArray with the 976 // Allocate the JSArray object together with space for a FixedArray with the
977 // requested elements. 977 // requested elements.
978 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 978 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
979 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize, 979 __ AllocateInNewSpace(JSArray::kSize + FixedArray::kHeaderSize,
980 times_half_pointer_size, // array_size is a smi. 980 times_half_pointer_size, // array_size is a smi.
981 array_size, 981 array_size,
982 result, 982 result,
983 elements_array_end, 983 elements_array_end,
984 scratch, 984 scratch,
985 gc_required, 985 gc_required,
986 TAG_OBJECT); 986 TAG_OBJECT);
987 987
988 // Allocated the JSArray. Now initialize the fields except for the elements 988 // Allocated the JSArray. Now initialize the fields except for the elements
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 if (construct_call) { 1093 if (construct_call) {
1094 __ pop(edi); 1094 __ pop(edi);
1095 } 1095 }
1096 __ ret(kPointerSize); 1096 __ ret(kPointerSize);
1097 1097
1098 // Check for one argument. Bail out if argument is not smi or if it is 1098 // Check for one argument. Bail out if argument is not smi or if it is
1099 // negative. 1099 // negative.
1100 __ bind(&argc_one_or_more); 1100 __ bind(&argc_one_or_more);
1101 __ cmp(eax, 1); 1101 __ cmp(eax, 1);
1102 __ j(not_equal, &argc_two_or_more); 1102 __ j(not_equal, &argc_two_or_more);
1103 ASSERT(kSmiTag == 0); 1103 STATIC_ASSERT(kSmiTag == 0);
1104 __ mov(ecx, Operand(esp, (push_count + 1) * kPointerSize)); 1104 __ mov(ecx, Operand(esp, (push_count + 1) * kPointerSize));
1105 __ test(ecx, Operand(ecx)); 1105 __ test(ecx, Operand(ecx));
1106 __ j(not_zero, &not_empty_array); 1106 __ j(not_zero, &not_empty_array);
1107 1107
1108 // The single argument passed is zero, so we jump to the code above used to 1108 // The single argument passed is zero, so we jump to the code above used to
1109 // handle the case of no arguments passed. To adapt the stack for that we move 1109 // handle the case of no arguments passed. To adapt the stack for that we move
1110 // the return address and the pushed constructor (if pushed) one stack slot up 1110 // the return address and the pushed constructor (if pushed) one stack slot up
1111 // thereby removing the passed argument. Argc is also on the stack - at the 1111 // thereby removing the passed argument. Argc is also on the stack - at the
1112 // bottom - and it needs to be changed from 1 to 0 to have the call into the 1112 // bottom - and it needs to be changed from 1 to 0 to have the call into the
1113 // runtime system work in case a GC is required. 1113 // runtime system work in case a GC is required.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 __ IncrementCounter(counters->array_function_native(), 1); 1148 __ IncrementCounter(counters->array_function_native(), 1);
1149 __ mov(eax, ebx); 1149 __ mov(eax, ebx);
1150 __ pop(ebx); 1150 __ pop(ebx);
1151 if (construct_call) { 1151 if (construct_call) {
1152 __ pop(edi); 1152 __ pop(edi);
1153 } 1153 }
1154 __ ret(2 * kPointerSize); 1154 __ ret(2 * kPointerSize);
1155 1155
1156 // Handle construction of an array from a list of arguments. 1156 // Handle construction of an array from a list of arguments.
1157 __ bind(&argc_two_or_more); 1157 __ bind(&argc_two_or_more);
1158 ASSERT(kSmiTag == 0); 1158 STATIC_ASSERT(kSmiTag == 0);
1159 __ SmiTag(eax); // Convet argc to a smi. 1159 __ SmiTag(eax); // Convet argc to a smi.
1160 // eax: array_size (smi) 1160 // eax: array_size (smi)
1161 // edi: constructor 1161 // edi: constructor
1162 // esp[0] : argc 1162 // esp[0] : argc
1163 // esp[4]: constructor (only if construct_call) 1163 // esp[4]: constructor (only if construct_call)
1164 // esp[8] : return address 1164 // esp[8] : return address
1165 // esp[C] : last argument 1165 // esp[C] : last argument
1166 AllocateJSArray(masm, 1166 AllocateJSArray(masm,
1167 edi, 1167 edi,
1168 eax, 1168 eax,
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 1430
1431 // Store the arguments adaptor context sentinel. 1431 // Store the arguments adaptor context sentinel.
1432 __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 1432 __ push(Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
1433 1433
1434 // Push the function on the stack. 1434 // Push the function on the stack.
1435 __ push(edi); 1435 __ push(edi);
1436 1436
1437 // Preserve the number of arguments on the stack. Must preserve eax, 1437 // Preserve the number of arguments on the stack. Must preserve eax,
1438 // ebx and ecx because these registers are used when copying the 1438 // ebx and ecx because these registers are used when copying the
1439 // arguments and the receiver. 1439 // arguments and the receiver.
1440 ASSERT(kSmiTagSize == 1); 1440 STATIC_ASSERT(kSmiTagSize == 1);
1441 __ lea(edi, Operand(eax, eax, times_1, kSmiTag)); 1441 __ lea(edi, Operand(eax, eax, times_1, kSmiTag));
1442 __ push(edi); 1442 __ push(edi);
1443 } 1443 }
1444 1444
1445 1445
1446 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { 1446 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) {
1447 // Retrieve the number of arguments from the stack. 1447 // Retrieve the number of arguments from the stack.
1448 __ mov(ebx, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); 1448 __ mov(ebx, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset));
1449 1449
1450 // Leave the frame. 1450 // Leave the frame.
1451 __ leave(); 1451 __ leave();
1452 1452
1453 // Remove caller arguments from the stack. 1453 // Remove caller arguments from the stack.
1454 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 1454 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
1455 __ pop(ecx); 1455 __ pop(ecx);
1456 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver 1456 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver
1457 __ push(ecx); 1457 __ push(ecx);
1458 } 1458 }
1459 1459
1460 1460
1461 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { 1461 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1462 // ----------- S t a t e ------------- 1462 // ----------- S t a t e -------------
1463 // -- eax : actual number of arguments 1463 // -- eax : actual number of arguments
1464 // -- ebx : expected number of arguments 1464 // -- ebx : expected number of arguments
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1607 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1608 generator.Generate(); 1608 generator.Generate();
1609 } 1609 }
1610 1610
1611 1611
1612 #undef __ 1612 #undef __
1613 } 1613 }
1614 } // namespace v8::internal 1614 } // namespace v8::internal
1615 1615
1616 #endif // V8_TARGET_ARCH_IA32 1616 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698