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

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

Issue 8381014: Fixing dead code in empty array init. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported change to MIPS. 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ia32/builtins-ia32.cc » ('j') | src/ia32/builtins-ia32.cc » ('J')
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Register scratch3, 97 Register scratch3,
98 Label* gc_required) { 98 Label* gc_required) {
99 const int initial_capacity = JSArray::kPreallocatedArrayElements; 99 const int initial_capacity = JSArray::kPreallocatedArrayElements;
100 STATIC_ASSERT(initial_capacity >= 0); 100 STATIC_ASSERT(initial_capacity >= 0);
101 // Load the initial map from the array function. 101 // Load the initial map from the array function.
102 __ ldr(scratch1, FieldMemOperand(array_function, 102 __ ldr(scratch1, FieldMemOperand(array_function,
103 JSFunction::kPrototypeOrInitialMapOffset)); 103 JSFunction::kPrototypeOrInitialMapOffset));
104 104
105 // Allocate the JSArray object together with space for a fixed array with the 105 // Allocate the JSArray object together with space for a fixed array with the
106 // requested elements. 106 // requested elements.
107 int size = JSArray::kSize + FixedArray::SizeFor(initial_capacity); 107 int size = JSArray::kSize;
108 if (initial_capacity > 0) {
109 size += FixedArray::SizeFor(initial_capacity);
110 }
108 __ AllocateInNewSpace(size, 111 __ AllocateInNewSpace(size,
109 result, 112 result,
110 scratch2, 113 scratch2,
111 scratch3, 114 scratch3,
112 gc_required, 115 gc_required,
113 TAG_OBJECT); 116 TAG_OBJECT);
114 117
115 // Allocated the JSArray. Now initialize the fields except for the elements 118 // Allocated the JSArray. Now initialize the fields except for the elements
116 // array. 119 // array.
117 // result: JSObject 120 // result: JSObject
118 // scratch1: initial map 121 // scratch1: initial map
119 // scratch2: start of next object 122 // scratch2: start of next object
120 __ str(scratch1, FieldMemOperand(result, JSObject::kMapOffset)); 123 __ str(scratch1, FieldMemOperand(result, JSObject::kMapOffset));
121 __ LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex); 124 __ LoadRoot(scratch1, Heap::kEmptyFixedArrayRootIndex);
122 __ str(scratch1, FieldMemOperand(result, JSArray::kPropertiesOffset)); 125 __ str(scratch1, FieldMemOperand(result, JSArray::kPropertiesOffset));
123 // Field JSArray::kElementsOffset is initialized later. 126 // Field JSArray::kElementsOffset is initialized later.
124 __ mov(scratch3, Operand(0, RelocInfo::NONE)); 127 __ mov(scratch3, Operand(0, RelocInfo::NONE));
125 __ str(scratch3, FieldMemOperand(result, JSArray::kLengthOffset)); 128 __ str(scratch3, FieldMemOperand(result, JSArray::kLengthOffset));
126 129
130 if (initial_capacity == 0) {
131 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset));
132 return;
133 }
134
127 // Calculate the location of the elements array and set elements array member 135 // Calculate the location of the elements array and set elements array member
128 // of the JSArray. 136 // of the JSArray.
129 // result: JSObject 137 // result: JSObject
130 // scratch2: start of next object 138 // scratch2: start of next object
131 __ add(scratch1, result, Operand(JSArray::kSize)); 139 __ add(scratch1, result, Operand(JSArray::kSize));
132 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset)); 140 __ str(scratch1, FieldMemOperand(result, JSArray::kElementsOffset));
133 141
134 // Clear the heap tag on the elements array. 142 // Clear the heap tag on the elements array.
135 STATIC_ASSERT(kSmiTag == 0); 143 STATIC_ASSERT(kSmiTag == 0);
Kevin Millikin (Chromium) 2011/10/27 10:35:54 I can't figure out why the following code depends
136 __ sub(scratch1, scratch1, Operand(kHeapObjectTag)); 144 __ sub(scratch1, scratch1, Operand(kHeapObjectTag));
137 145
138 // Initialize the FixedArray and fill it with holes. FixedArray length is 146 // Initialize the FixedArray and fill it with holes. FixedArray length is
139 // stored as a smi. 147 // stored as a smi.
140 // result: JSObject 148 // result: JSObject
141 // scratch1: elements array (untagged) 149 // scratch1: elements array (untagged)
142 // scratch2: start of next object 150 // scratch2: start of next object
143 __ LoadRoot(scratch3, Heap::kFixedArrayMapRootIndex); 151 __ LoadRoot(scratch3, Heap::kFixedArrayMapRootIndex);
144 ASSERT_EQ(0 * kPointerSize, FixedArray::kMapOffset); 152 ASSERT_EQ(0 * kPointerSize, FixedArray::kMapOffset);
Kevin Millikin (Chromium) 2011/10/27 10:35:54 This can be a static assert.
145 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); 153 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
146 __ mov(scratch3, Operand(Smi::FromInt(initial_capacity))); 154 __ mov(scratch3, Operand(Smi::FromInt(initial_capacity)));
147 ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset); 155 ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset);
Kevin Millikin (Chromium) 2011/10/27 10:35:54 This can be a static assert.
148 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); 156 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
149 157
150 // Fill the FixedArray with the hole value. Inline the code if short. 158 // Fill the FixedArray with the hole value. Inline the code if short.
151 if (initial_capacity == 0) return;
152 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); 159 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize);
Kevin Millikin (Chromium) 2011/10/27 10:35:54 This can be a static assert.
153 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex); 160 __ LoadRoot(scratch3, Heap::kTheHoleValueRootIndex);
154 static const int kLoopUnfoldLimit = 4; 161 static const int kLoopUnfoldLimit = 4;
155 if (initial_capacity <= kLoopUnfoldLimit) { 162 if (initial_capacity <= kLoopUnfoldLimit) {
156 for (int i = 0; i < initial_capacity; i++) { 163 for (int i = 0; i < initial_capacity; i++) {
157 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex)); 164 __ str(scratch3, MemOperand(scratch1, kPointerSize, PostIndex));
158 } 165 }
159 } else { 166 } else {
160 Label loop, entry; 167 Label loop, entry;
161 __ add(scratch2, scratch1, Operand(initial_capacity * kPointerSize)); 168 __ add(scratch2, scratch1, Operand(initial_capacity * kPointerSize));
162 __ b(&entry); 169 __ b(&entry);
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 __ bind(&dont_adapt_arguments); 1715 __ bind(&dont_adapt_arguments);
1709 __ Jump(r3); 1716 __ Jump(r3);
1710 } 1717 }
1711 1718
1712 1719
1713 #undef __ 1720 #undef __
1714 1721
1715 } } // namespace v8::internal 1722 } } // namespace v8::internal
1716 1723
1717 #endif // V8_TARGET_ARCH_ARM 1724 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ia32/builtins-ia32.cc » ('j') | src/ia32/builtins-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698