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

Side by Side Diff: src/mips/builtins-mips.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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // ----------------------------------- 116 // -----------------------------------
117 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; 117 Label generic_array_code, one_or_more_arguments, two_or_more_arguments;
118 118
119 // Get the InternalArray function. 119 // Get the InternalArray function.
120 GenerateLoadInternalArrayFunction(masm, a1); 120 GenerateLoadInternalArrayFunction(masm, a1);
121 121
122 if (FLAG_debug_code) { 122 if (FLAG_debug_code) {
123 // Initial map for the builtin InternalArray functions should be maps. 123 // Initial map for the builtin InternalArray functions should be maps.
124 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); 124 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
125 __ And(t0, a2, Operand(kSmiTagMask)); 125 __ And(t0, a2, Operand(kSmiTagMask));
126 __ Assert(ne, "Unexpected initial map for InternalArray function", 126 __ Assert(ne, kUnexpectedInitialMapForInternalArrayFunction,
127 t0, Operand(zero_reg)); 127 t0, Operand(zero_reg));
128 __ GetObjectType(a2, a3, t0); 128 __ GetObjectType(a2, a3, t0);
129 __ Assert(eq, "Unexpected initial map for InternalArray function", 129 __ Assert(eq, kUnexpectedInitialMapForInternalArrayFunction,
130 t0, Operand(MAP_TYPE)); 130 t0, Operand(MAP_TYPE));
131 } 131 }
132 132
133 // Run the native code for the InternalArray function called as a normal 133 // Run the native code for the InternalArray function called as a normal
134 // function. 134 // function.
135 // Tail call a stub. 135 // Tail call a stub.
136 InternalArrayConstructorStub stub(masm->isolate()); 136 InternalArrayConstructorStub stub(masm->isolate());
137 __ TailCallStub(&stub); 137 __ TailCallStub(&stub);
138 } 138 }
139 139
140 140
141 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { 141 void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
142 // ----------- S t a t e ------------- 142 // ----------- S t a t e -------------
143 // -- a0 : number of arguments 143 // -- a0 : number of arguments
144 // -- ra : return address 144 // -- ra : return address
145 // -- sp[...]: constructor arguments 145 // -- sp[...]: constructor arguments
146 // ----------------------------------- 146 // -----------------------------------
147 Label generic_array_code; 147 Label generic_array_code;
148 148
149 // Get the Array function. 149 // Get the Array function.
150 GenerateLoadArrayFunction(masm, a1); 150 GenerateLoadArrayFunction(masm, a1);
151 151
152 if (FLAG_debug_code) { 152 if (FLAG_debug_code) {
153 // Initial map for the builtin Array functions should be maps. 153 // Initial map for the builtin Array functions should be maps.
154 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); 154 __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset));
155 __ And(t0, a2, Operand(kSmiTagMask)); 155 __ And(t0, a2, Operand(kSmiTagMask));
156 __ Assert(ne, "Unexpected initial map for Array function (1)", 156 __ Assert(ne, kUnexpectedInitialMapForArrayFunction1,
157 t0, Operand(zero_reg)); 157 t0, Operand(zero_reg));
158 __ GetObjectType(a2, a3, t0); 158 __ GetObjectType(a2, a3, t0);
159 __ Assert(eq, "Unexpected initial map for Array function (2)", 159 __ Assert(eq, kUnexpectedInitialMapForArrayFunction2,
160 t0, Operand(MAP_TYPE)); 160 t0, Operand(MAP_TYPE));
161 } 161 }
162 162
163 // Run the native code for the Array function called as a normal function. 163 // Run the native code for the Array function called as a normal function.
164 // Tail call a stub. 164 // Tail call a stub.
165 Handle<Object> undefined_sentinel( 165 Handle<Object> undefined_sentinel(
166 masm->isolate()->heap()->undefined_value(), 166 masm->isolate()->heap()->undefined_value(),
167 masm->isolate()); 167 masm->isolate());
168 __ li(a2, Operand(undefined_sentinel)); 168 __ li(a2, Operand(undefined_sentinel));
169 ArrayConstructorStub stub(masm->isolate()); 169 ArrayConstructorStub stub(masm->isolate());
170 __ TailCallStub(&stub); 170 __ TailCallStub(&stub);
171 } 171 }
172 172
173 173
174 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { 174 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) {
175 // ----------- S t a t e ------------- 175 // ----------- S t a t e -------------
176 // -- a0 : number of arguments 176 // -- a0 : number of arguments
177 // -- a1 : constructor function 177 // -- a1 : constructor function
178 // -- ra : return address 178 // -- ra : return address
179 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) 179 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based)
180 // -- sp[argc * 4] : receiver 180 // -- sp[argc * 4] : receiver
181 // ----------------------------------- 181 // -----------------------------------
182 Counters* counters = masm->isolate()->counters(); 182 Counters* counters = masm->isolate()->counters();
183 __ IncrementCounter(counters->string_ctor_calls(), 1, a2, a3); 183 __ IncrementCounter(counters->string_ctor_calls(), 1, a2, a3);
184 184
185 Register function = a1; 185 Register function = a1;
186 if (FLAG_debug_code) { 186 if (FLAG_debug_code) {
187 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, a2); 187 __ LoadGlobalFunction(Context::STRING_FUNCTION_INDEX, a2);
188 __ Assert(eq, "Unexpected String function", function, Operand(a2)); 188 __ Assert(eq, kUnexpectedStringFunction, function, Operand(a2));
189 } 189 }
190 190
191 // Load the first arguments in a0 and get rid of the rest. 191 // Load the first arguments in a0 and get rid of the rest.
192 Label no_arguments; 192 Label no_arguments;
193 __ Branch(&no_arguments, eq, a0, Operand(zero_reg)); 193 __ Branch(&no_arguments, eq, a0, Operand(zero_reg));
194 // First args = sp[(argc - 1) * 4]. 194 // First args = sp[(argc - 1) * 4].
195 __ Subu(a0, a0, Operand(1)); 195 __ Subu(a0, a0, Operand(1));
196 __ sll(a0, a0, kPointerSizeLog2); 196 __ sll(a0, a0, kPointerSizeLog2);
197 __ Addu(sp, a0, sp); 197 __ Addu(sp, a0, sp);
198 __ lw(a0, MemOperand(sp)); 198 __ lw(a0, MemOperand(sp));
(...skipping 25 matching lines...) Expand all
224 a3, // Scratch. 224 a3, // Scratch.
225 t0, // Scratch. 225 t0, // Scratch.
226 &gc_required, 226 &gc_required,
227 TAG_OBJECT); 227 TAG_OBJECT);
228 228
229 // Initialising the String Object. 229 // Initialising the String Object.
230 Register map = a3; 230 Register map = a3;
231 __ LoadGlobalFunctionInitialMap(function, map, t0); 231 __ LoadGlobalFunctionInitialMap(function, map, t0);
232 if (FLAG_debug_code) { 232 if (FLAG_debug_code) {
233 __ lbu(t0, FieldMemOperand(map, Map::kInstanceSizeOffset)); 233 __ lbu(t0, FieldMemOperand(map, Map::kInstanceSizeOffset));
234 __ Assert(eq, "Unexpected string wrapper instance size", 234 __ Assert(eq, kUnexpectedStringWrapperInstanceSize,
235 t0, Operand(JSValue::kSize >> kPointerSizeLog2)); 235 t0, Operand(JSValue::kSize >> kPointerSizeLog2));
236 __ lbu(t0, FieldMemOperand(map, Map::kUnusedPropertyFieldsOffset)); 236 __ lbu(t0, FieldMemOperand(map, Map::kUnusedPropertyFieldsOffset));
237 __ Assert(eq, "Unexpected unused properties of string wrapper", 237 __ Assert(eq, kUnexpectedUnusedPropertiesOfStringWrapper,
238 t0, Operand(zero_reg)); 238 t0, Operand(zero_reg));
239 } 239 }
240 __ sw(map, FieldMemOperand(v0, HeapObject::kMapOffset)); 240 __ sw(map, FieldMemOperand(v0, HeapObject::kMapOffset));
241 241
242 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); 242 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex);
243 __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); 243 __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset));
244 __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); 244 __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset));
245 245
246 __ sw(argument, FieldMemOperand(v0, JSValue::kValueOffset)); 246 __ sw(argument, FieldMemOperand(v0, JSValue::kValueOffset));
247 247
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); 482 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize);
483 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); 483 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
484 if (count_constructions) { 484 if (count_constructions) {
485 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); 485 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset));
486 __ Ext(a0, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, 486 __ Ext(a0, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
487 kBitsPerByte); 487 kBitsPerByte);
488 __ sll(t0, a0, kPointerSizeLog2); 488 __ sll(t0, a0, kPointerSizeLog2);
489 __ addu(a0, t5, t0); 489 __ addu(a0, t5, t0);
490 // a0: offset of first field after pre-allocated fields 490 // a0: offset of first field after pre-allocated fields
491 if (FLAG_debug_code) { 491 if (FLAG_debug_code) {
492 __ Assert(le, "Unexpected number of pre-allocated property fields.", 492 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields,
493 a0, Operand(t6)); 493 a0, Operand(t6));
494 } 494 }
495 __ InitializeFieldsWithFiller(t5, a0, t7); 495 __ InitializeFieldsWithFiller(t5, a0, t7);
496 // To allow for truncation. 496 // To allow for truncation.
497 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); 497 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex);
498 } 498 }
499 __ InitializeFieldsWithFiller(t5, t6, t7); 499 __ InitializeFieldsWithFiller(t5, t6, t7);
500 500
501 // Add the object tag to make the JSObject real, so that we can continue 501 // Add the object tag to make the JSObject real, so that we can continue
502 // and jump into the continuation code at any time from now on. Any 502 // and jump into the continuation code at any time from now on. Any
(...skipping 12 matching lines...) Expand all
515 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); 515 __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset));
516 __ Ext(t6, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, 516 __ Ext(t6, a0, Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
517 kBitsPerByte); 517 kBitsPerByte);
518 __ Addu(a3, a3, Operand(t6)); 518 __ Addu(a3, a3, Operand(t6));
519 __ Ext(t6, a0, Map::kInObjectPropertiesByte * kBitsPerByte, 519 __ Ext(t6, a0, Map::kInObjectPropertiesByte * kBitsPerByte,
520 kBitsPerByte); 520 kBitsPerByte);
521 __ subu(a3, a3, t6); 521 __ subu(a3, a3, t6);
522 522
523 // Done if no extra properties are to be allocated. 523 // Done if no extra properties are to be allocated.
524 __ Branch(&allocated, eq, a3, Operand(zero_reg)); 524 __ Branch(&allocated, eq, a3, Operand(zero_reg));
525 __ Assert(greater_equal, "Property allocation count failed.", 525 __ Assert(greater_equal, kPropertyAllocationCountFailed,
526 a3, Operand(zero_reg)); 526 a3, Operand(zero_reg));
527 527
528 // Scale the number of elements by pointer size and add the header for 528 // Scale the number of elements by pointer size and add the header for
529 // FixedArrays to the start of the next object calculation from above. 529 // FixedArrays to the start of the next object calculation from above.
530 // a1: constructor 530 // a1: constructor
531 // a3: number of elements in properties array 531 // a3: number of elements in properties array
532 // t4: JSObject 532 // t4: JSObject
533 // t5: start of next object 533 // t5: start of next object
534 __ Addu(a0, a3, Operand(FixedArray::kHeaderSize / kPointerSize)); 534 __ Addu(a0, a3, Operand(FixedArray::kHeaderSize / kPointerSize));
535 __ Allocate( 535 __ Allocate(
(...skipping 26 matching lines...) Expand all
562 // t4: JSObject 562 // t4: JSObject
563 // t5: FixedArray (not tagged) 563 // t5: FixedArray (not tagged)
564 __ sll(t3, a3, kPointerSizeLog2); 564 __ sll(t3, a3, kPointerSizeLog2);
565 __ addu(t6, a2, t3); // End of object. 565 __ addu(t6, a2, t3); // End of object.
566 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); 566 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize);
567 { Label loop, entry; 567 { Label loop, entry;
568 if (count_constructions) { 568 if (count_constructions) {
569 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); 569 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex);
570 } else if (FLAG_debug_code) { 570 } else if (FLAG_debug_code) {
571 __ LoadRoot(t8, Heap::kUndefinedValueRootIndex); 571 __ LoadRoot(t8, Heap::kUndefinedValueRootIndex);
572 __ Assert(eq, "Undefined value not loaded.", t7, Operand(t8)); 572 __ Assert(eq, kUndefinedValueNotLoaded, t7, Operand(t8));
573 } 573 }
574 __ jmp(&entry); 574 __ jmp(&entry);
575 __ bind(&loop); 575 __ bind(&loop);
576 __ sw(t7, MemOperand(a2)); 576 __ sw(t7, MemOperand(a2));
577 __ addiu(a2, a2, kPointerSize); 577 __ addiu(a2, a2, kPointerSize);
578 __ bind(&entry); 578 __ bind(&entry);
579 __ Branch(&loop, less, a2, Operand(t6)); 579 __ Branch(&loop, less, a2, Operand(t6));
580 } 580 }
581 581
582 // Store the initialized FixedArray into the properties field of 582 // Store the initialized FixedArray into the properties field of
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 __ bind(&dont_adapt_arguments); 1515 __ bind(&dont_adapt_arguments);
1516 __ Jump(a3); 1516 __ Jump(a3);
1517 } 1517 }
1518 1518
1519 1519
1520 #undef __ 1520 #undef __
1521 1521
1522 } } // namespace v8::internal 1522 } } // namespace v8::internal
1523 1523
1524 #endif // V8_TARGET_ARCH_MIPS 1524 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« src/compiler.cc ('K') | « src/lithium.cc ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698