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

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

Issue 20843012: Extract hardcoded error strings into a single place and replace them with enum. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: styles fixed Created 7 years, 4 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
OLDNEW
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); 242 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex);
243 if (count_constructions) { 243 if (count_constructions) {
244 __ movzxbq(rsi, 244 __ movzxbq(rsi,
245 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset)); 245 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset));
246 __ lea(rsi, 246 __ lea(rsi,
247 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize)); 247 Operand(rbx, rsi, times_pointer_size, JSObject::kHeaderSize));
248 // rsi: offset of first field after pre-allocated fields 248 // rsi: offset of first field after pre-allocated fields
249 if (FLAG_debug_code) { 249 if (FLAG_debug_code) {
250 __ cmpq(rsi, rdi); 250 __ cmpq(rsi, rdi);
251 __ Assert(less_equal, 251 __ Assert(less_equal,
252 "Unexpected number of pre-allocated property fields."); 252 kUnexpectedNumberOfPreAllocatedPropertyFields);
253 } 253 }
254 __ InitializeFieldsWithFiller(rcx, rsi, rdx); 254 __ InitializeFieldsWithFiller(rcx, rsi, rdx);
255 __ LoadRoot(rdx, Heap::kOnePointerFillerMapRootIndex); 255 __ LoadRoot(rdx, Heap::kOnePointerFillerMapRootIndex);
256 } 256 }
257 __ InitializeFieldsWithFiller(rcx, rdi, rdx); 257 __ InitializeFieldsWithFiller(rcx, rdi, rdx);
258 258
259 // Add the object tag to make the JSObject real, so that we can continue 259 // Add the object tag to make the JSObject real, so that we can continue
260 // and jump into the continuation code at any time from now on. Any 260 // and jump into the continuation code at any time from now on. Any
261 // failures need to undo the allocation, so that the heap is in a 261 // failures need to undo the allocation, so that the heap is in a
262 // consistent state and verifiable. 262 // consistent state and verifiable.
(...skipping 10 matching lines...) Expand all
273 // Calculate total properties described map. 273 // Calculate total properties described map.
274 __ movzxbq(rdx, FieldOperand(rax, Map::kUnusedPropertyFieldsOffset)); 274 __ movzxbq(rdx, FieldOperand(rax, Map::kUnusedPropertyFieldsOffset));
275 __ movzxbq(rcx, 275 __ movzxbq(rcx,
276 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset)); 276 FieldOperand(rax, Map::kPreAllocatedPropertyFieldsOffset));
277 __ addq(rdx, rcx); 277 __ addq(rdx, rcx);
278 // Calculate unused properties past the end of the in-object properties. 278 // Calculate unused properties past the end of the in-object properties.
279 __ movzxbq(rcx, FieldOperand(rax, Map::kInObjectPropertiesOffset)); 279 __ movzxbq(rcx, FieldOperand(rax, Map::kInObjectPropertiesOffset));
280 __ subq(rdx, rcx); 280 __ subq(rdx, rcx);
281 // Done if no extra properties are to be allocated. 281 // Done if no extra properties are to be allocated.
282 __ j(zero, &allocated); 282 __ j(zero, &allocated);
283 __ Assert(positive, "Property allocation count failed."); 283 __ Assert(positive, kPropertyAllocationCountFailed);
284 284
285 // Scale the number of elements by pointer size and add the header for 285 // Scale the number of elements by pointer size and add the header for
286 // FixedArrays to the start of the next object calculation from above. 286 // FixedArrays to the start of the next object calculation from above.
287 // rbx: JSObject 287 // rbx: JSObject
288 // rdi: start of next object (will be start of FixedArray) 288 // rdi: start of next object (will be start of FixedArray)
289 // rdx: number of elements in properties array 289 // rdx: number of elements in properties array
290 __ Allocate(FixedArray::kHeaderSize, 290 __ Allocate(FixedArray::kHeaderSize,
291 times_pointer_size, 291 times_pointer_size,
292 rdx, 292 rdx,
293 rdi, 293 rdi,
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 __ j(not_equal, &not_no_registers, Label::kNear); 716 __ j(not_equal, &not_no_registers, Label::kNear);
717 __ ret(1 * kPointerSize); // Remove state. 717 __ ret(1 * kPointerSize); // Remove state.
718 718
719 __ bind(&not_no_registers); 719 __ bind(&not_no_registers);
720 __ movq(rax, Operand(rsp, 2 * kPointerSize)); 720 __ movq(rax, Operand(rsp, 2 * kPointerSize));
721 __ cmpq(r10, Immediate(FullCodeGenerator::TOS_REG)); 721 __ cmpq(r10, Immediate(FullCodeGenerator::TOS_REG));
722 __ j(not_equal, &not_tos_rax, Label::kNear); 722 __ j(not_equal, &not_tos_rax, Label::kNear);
723 __ ret(2 * kPointerSize); // Remove state, rax. 723 __ ret(2 * kPointerSize); // Remove state, rax.
724 724
725 __ bind(&not_tos_rax); 725 __ bind(&not_tos_rax);
726 __ Abort("no cases left"); 726 __ Abort(kNoCasesLeft);
727 } 727 }
728 728
729 729
730 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { 730 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) {
731 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); 731 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER);
732 } 732 }
733 733
734 734
735 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { 735 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) {
736 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); 736 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 1106
1107 // Get the InternalArray function. 1107 // Get the InternalArray function.
1108 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, rdi); 1108 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, rdi);
1109 1109
1110 if (FLAG_debug_code) { 1110 if (FLAG_debug_code) {
1111 // Initial map for the builtin InternalArray functions should be maps. 1111 // Initial map for the builtin InternalArray functions should be maps.
1112 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 1112 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
1113 // Will both indicate a NULL and a Smi. 1113 // Will both indicate a NULL and a Smi.
1114 STATIC_ASSERT(kSmiTag == 0); 1114 STATIC_ASSERT(kSmiTag == 0);
1115 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); 1115 Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
1116 __ Check(not_smi, "Unexpected initial map for InternalArray function"); 1116 __ Check(not_smi, kUnexpectedInitialMapForInternalArrayFunction);
1117 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1117 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1118 __ Check(equal, "Unexpected initial map for InternalArray function"); 1118 __ Check(equal, kUnexpectedInitialMapForInternalArrayFunction);
1119 } 1119 }
1120 1120
1121 // Run the native code for the InternalArray function called as a normal 1121 // Run the native code for the InternalArray function called as a normal
1122 // function. 1122 // function.
1123 // tail call a stub 1123 // tail call a stub
1124 InternalArrayConstructorStub stub(masm->isolate()); 1124 InternalArrayConstructorStub stub(masm->isolate());
1125 __ TailCallStub(&stub); 1125 __ TailCallStub(&stub);
1126 } 1126 }
1127 1127
1128 1128
1129 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { 1129 void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
1130 // ----------- S t a t e ------------- 1130 // ----------- S t a t e -------------
1131 // -- rax : argc 1131 // -- rax : argc
1132 // -- rsp[0] : return address 1132 // -- rsp[0] : return address
1133 // -- rsp[8] : last argument 1133 // -- rsp[8] : last argument
1134 // ----------------------------------- 1134 // -----------------------------------
1135 Label generic_array_code; 1135 Label generic_array_code;
1136 1136
1137 // Get the Array function. 1137 // Get the Array function.
1138 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi); 1138 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi);
1139 1139
1140 if (FLAG_debug_code) { 1140 if (FLAG_debug_code) {
1141 // Initial map for the builtin Array functions should be maps. 1141 // Initial map for the builtin Array functions should be maps.
1142 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 1142 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
1143 // Will both indicate a NULL and a Smi. 1143 // Will both indicate a NULL and a Smi.
1144 STATIC_ASSERT(kSmiTag == 0); 1144 STATIC_ASSERT(kSmiTag == 0);
1145 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); 1145 Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
1146 __ Check(not_smi, "Unexpected initial map for Array function"); 1146 __ Check(not_smi, kUnexpectedInitialMapForArrayFunction);
1147 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1147 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1148 __ Check(equal, "Unexpected initial map for Array function"); 1148 __ Check(equal, kUnexpectedInitialMapForArrayFunction);
1149 } 1149 }
1150 1150
1151 // Run the native code for the Array function called as a normal function. 1151 // Run the native code for the Array function called as a normal function.
1152 // tail call a stub 1152 // tail call a stub
1153 Handle<Object> undefined_sentinel( 1153 Handle<Object> undefined_sentinel(
1154 masm->isolate()->heap()->undefined_value(), 1154 masm->isolate()->heap()->undefined_value(),
1155 masm->isolate()); 1155 masm->isolate());
1156 __ Move(rbx, undefined_sentinel); 1156 __ Move(rbx, undefined_sentinel);
1157 ArrayConstructorStub stub(masm->isolate()); 1157 ArrayConstructorStub stub(masm->isolate());
1158 __ TailCallStub(&stub); 1158 __ TailCallStub(&stub);
1159 } 1159 }
1160 1160
1161 1161
1162 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 1162 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
1163 // ----------- S t a t e ------------- 1163 // ----------- S t a t e -------------
1164 // -- rax : number of arguments 1164 // -- rax : number of arguments
1165 // -- rdi : constructor function 1165 // -- rdi : constructor function
1166 // -- rsp[0] : return address 1166 // -- rsp[0] : return address
1167 // -- rsp[(argc - n) * 8] : arg[n] (zero-based) 1167 // -- rsp[(argc - n) * 8] : arg[n] (zero-based)
1168 // -- rsp[(argc + 1) * 8] : receiver 1168 // -- rsp[(argc + 1) * 8] : receiver
1169 // ----------------------------------- 1169 // -----------------------------------
1170 Counters* counters = masm->isolate()->counters(); 1170 Counters* counters = masm->isolate()->counters();
1171 __ IncrementCounter(counters->string_ctor_calls(), 1); 1171 __ IncrementCounter(counters->string_ctor_calls(), 1);
1172 1172
1173 if (FLAG_debug_code) { 1173 if (FLAG_debug_code) {
1174 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx); 1174 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, rcx);
1175 __ cmpq(rdi, rcx); 1175 __ cmpq(rdi, rcx);
1176 __ Assert(equal, "Unexpected String function"); 1176 __ Assert(equal, kUnexpectedStringFunction);
1177 } 1177 }
1178 1178
1179 // Load the first argument into rax and get rid of the rest 1179 // Load the first argument into rax and get rid of the rest
1180 // (including the receiver). 1180 // (including the receiver).
1181 Label no_arguments; 1181 Label no_arguments;
1182 __ testq(rax, rax); 1182 __ testq(rax, rax);
1183 __ j(zero, &no_arguments); 1183 __ j(zero, &no_arguments);
1184 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0)); 1184 __ movq(rbx, Operand(rsp, rax, times_pointer_size, 0));
1185 __ pop(rcx); 1185 __ pop(rcx);
1186 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize)); 1186 __ lea(rsp, Operand(rsp, rax, times_pointer_size, kPointerSize));
(...skipping 25 matching lines...) Expand all
1212 rcx, // New allocation top (we ignore it). 1212 rcx, // New allocation top (we ignore it).
1213 no_reg, 1213 no_reg,
1214 &gc_required, 1214 &gc_required,
1215 TAG_OBJECT); 1215 TAG_OBJECT);
1216 1216
1217 // Set the map. 1217 // Set the map.
1218 __ LoadGlobalFunctionInitialMap(rdi, rcx); 1218 __ LoadGlobalFunctionInitialMap(rdi, rcx);
1219 if (FLAG_debug_code) { 1219 if (FLAG_debug_code) {
1220 __ cmpb(FieldOperand(rcx, Map::kInstanceSizeOffset), 1220 __ cmpb(FieldOperand(rcx, Map::kInstanceSizeOffset),
1221 Immediate(JSValue::kSize >> kPointerSizeLog2)); 1221 Immediate(JSValue::kSize >> kPointerSizeLog2));
1222 __ Assert(equal, "Unexpected string wrapper instance size"); 1222 __ Assert(equal, kUnexpectedStringWrapperInstanceSize);
1223 __ cmpb(FieldOperand(rcx, Map::kUnusedPropertyFieldsOffset), Immediate(0)); 1223 __ cmpb(FieldOperand(rcx, Map::kUnusedPropertyFieldsOffset), Immediate(0));
1224 __ Assert(equal, "Unexpected unused properties of string wrapper"); 1224 __ Assert(equal, kUnexpectedUnusedPropertiesOfStringWrapper);
1225 } 1225 }
1226 __ movq(FieldOperand(rax, HeapObject::kMapOffset), rcx); 1226 __ movq(FieldOperand(rax, HeapObject::kMapOffset), rcx);
1227 1227
1228 // Set properties and elements. 1228 // Set properties and elements.
1229 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex); 1229 __ LoadRoot(rcx, Heap::kEmptyFixedArrayRootIndex);
1230 __ movq(FieldOperand(rax, JSObject::kPropertiesOffset), rcx); 1230 __ movq(FieldOperand(rax, JSObject::kPropertiesOffset), rcx);
1231 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rcx); 1231 __ movq(FieldOperand(rax, JSObject::kElementsOffset), rcx);
1232 1232
1233 // Set the value. 1233 // Set the value.
1234 __ movq(FieldOperand(rax, JSValue::kValueOffset), rbx); 1234 __ movq(FieldOperand(rax, JSValue::kValueOffset), rbx);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1435 generator.Generate(); 1435 generator.Generate();
1436 } 1436 }
1437 1437
1438 1438
1439 #undef __ 1439 #undef __
1440 1440
1441 } } // namespace v8::internal 1441 } } // namespace v8::internal
1442 1442
1443 #endif // V8_TARGET_ARCH_X64 1443 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/compiler.cc ('K') | « src/objects.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698