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

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

Issue 2537453003: [arm][arm64] deal with holey array in the Apply builtin. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | src/builtins/arm64/builtins-arm64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 void Builtins::Generate_Apply(MacroAssembler* masm) { 2109 void Builtins::Generate_Apply(MacroAssembler* masm) {
2110 // ----------- S t a t e ------------- 2110 // ----------- S t a t e -------------
2111 // -- r0 : argumentsList 2111 // -- r0 : argumentsList
2112 // -- r1 : target 2112 // -- r1 : target
2113 // -- r3 : new.target (checked to be constructor or undefined) 2113 // -- r3 : new.target (checked to be constructor or undefined)
2114 // -- sp[0] : thisArgument 2114 // -- sp[0] : thisArgument
2115 // ----------------------------------- 2115 // -----------------------------------
2116 2116
2117 // Create the list of arguments from the array-like argumentsList. 2117 // Create the list of arguments from the array-like argumentsList.
2118 { 2118 {
2119 Label create_arguments, create_array, create_runtime, done_create; 2119 Label create_arguments, create_array, create_holey_array, create_runtime,
2120 done_create;
2120 __ JumpIfSmi(r0, &create_runtime); 2121 __ JumpIfSmi(r0, &create_runtime);
2121 2122
2122 // Load the map of argumentsList into r2. 2123 // Load the map of argumentsList into r2.
2123 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); 2124 __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset));
2124 2125
2125 // Load native context into r4. 2126 // Load native context into r4.
2126 __ ldr(r4, NativeContextMemOperand()); 2127 __ ldr(r4, NativeContextMemOperand());
2127 2128
2128 // Check if argumentsList is an (unmodified) arguments object. 2129 // Check if argumentsList is an (unmodified) arguments object.
2129 __ ldr(ip, ContextMemOperand(r4, Context::SLOPPY_ARGUMENTS_MAP_INDEX)); 2130 __ ldr(ip, ContextMemOperand(r4, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
(...skipping 23 matching lines...) Expand all
2153 __ bind(&create_arguments); 2154 __ bind(&create_arguments);
2154 __ ldr(r2, FieldMemOperand(r0, JSArgumentsObject::kLengthOffset)); 2155 __ ldr(r2, FieldMemOperand(r0, JSArgumentsObject::kLengthOffset));
2155 __ ldr(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); 2156 __ ldr(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
2156 __ ldr(ip, FieldMemOperand(r4, FixedArray::kLengthOffset)); 2157 __ ldr(ip, FieldMemOperand(r4, FixedArray::kLengthOffset));
2157 __ cmp(r2, ip); 2158 __ cmp(r2, ip);
2158 __ b(ne, &create_runtime); 2159 __ b(ne, &create_runtime);
2159 __ SmiUntag(r2); 2160 __ SmiUntag(r2);
2160 __ mov(r0, r4); 2161 __ mov(r0, r4);
2161 __ b(&done_create); 2162 __ b(&done_create);
2162 2163
2164 // For holey JSArrays we need to check that the array prototype chain
2165 // protector is intact and our prototype is the Array.prototype actually.
2166 __ bind(&create_holey_array);
2167 __ ldr(r2, FieldMemOperand(r2, Map::kPrototypeOffset));
2168 __ ldr(r4, ContextMemOperand(r4, Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2169 __ cmp(r2, r4);
2170 __ b(ne, &create_runtime);
2171 __ LoadRoot(r4, Heap::kArrayProtectorRootIndex);
2172 __ ldr(r2, FieldMemOperand(r4, PropertyCell::kValueOffset));
2173 __ cmp(r2, Operand(Smi::FromInt(Isolate::kProtectorValid)));
2174 __ b(ne, &create_runtime);
2175 __ ldr(r2, FieldMemOperand(r0, JSArray::kLengthOffset));
2176 __ ldr(r0, FieldMemOperand(r0, JSArray::kElementsOffset));
2177 __ SmiUntag(r2);
2178 __ b(&done_create);
2179
2163 // Try to create the list from a JSArray object. 2180 // Try to create the list from a JSArray object.
2181 // -- r2 and r4 must be preserved till bne create_holey_array.
2164 __ bind(&create_array); 2182 __ bind(&create_array);
2165 __ ldr(r2, FieldMemOperand(r2, Map::kBitField2Offset)); 2183 __ ldr(r5, FieldMemOperand(r2, Map::kBitField2Offset));
2166 __ DecodeField<Map::ElementsKindBits>(r2); 2184 __ DecodeField<Map::ElementsKindBits>(r5);
2167 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); 2185 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
2168 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); 2186 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
2169 STATIC_ASSERT(FAST_ELEMENTS == 2); 2187 STATIC_ASSERT(FAST_ELEMENTS == 2);
2170 __ cmp(r2, Operand(FAST_ELEMENTS)); 2188 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
2189 __ cmp(r5, Operand(FAST_HOLEY_ELEMENTS));
2171 __ b(hi, &create_runtime); 2190 __ b(hi, &create_runtime);
2172 __ cmp(r2, Operand(FAST_HOLEY_SMI_ELEMENTS)); 2191 // Only FAST_XXX after this point, FAST_HOLEY_XXX are odd values.
2173 __ b(eq, &create_runtime); 2192 __ tst(r5, Operand(1));
2193 __ b(ne, &create_holey_array);
2194 // FAST_SMI_ELEMENTS or FAST_ELEMENTS after this point.
2174 __ ldr(r2, FieldMemOperand(r0, JSArray::kLengthOffset)); 2195 __ ldr(r2, FieldMemOperand(r0, JSArray::kLengthOffset));
2175 __ ldr(r0, FieldMemOperand(r0, JSArray::kElementsOffset)); 2196 __ ldr(r0, FieldMemOperand(r0, JSArray::kElementsOffset));
2176 __ SmiUntag(r2); 2197 __ SmiUntag(r2);
2177 2198
2178 __ bind(&done_create); 2199 __ bind(&done_create);
2179 } 2200 }
2180 2201
2181 // Check for stack overflow. 2202 // Check for stack overflow.
2182 { 2203 {
2183 // Check the stack for overflow. We are not trying to catch interruptions 2204 // Check the stack for overflow. We are not trying to catch interruptions
(...skipping 14 matching lines...) Expand all
2198 // -- r1 : target 2219 // -- r1 : target
2199 // -- r0 : args (a FixedArray built from argumentsList) 2220 // -- r0 : args (a FixedArray built from argumentsList)
2200 // -- r2 : len (number of elements to push from args) 2221 // -- r2 : len (number of elements to push from args)
2201 // -- r3 : new.target (checked to be constructor or undefined) 2222 // -- r3 : new.target (checked to be constructor or undefined)
2202 // -- sp[0] : thisArgument 2223 // -- sp[0] : thisArgument
2203 // ----------------------------------- 2224 // -----------------------------------
2204 2225
2205 // Push arguments onto the stack (thisArgument is already on the stack). 2226 // Push arguments onto the stack (thisArgument is already on the stack).
2206 { 2227 {
2207 __ mov(r4, Operand(0)); 2228 __ mov(r4, Operand(0));
2229 __ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
2230 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex);
2208 Label done, loop; 2231 Label done, loop;
2209 __ bind(&loop); 2232 __ bind(&loop);
2210 __ cmp(r4, r2); 2233 __ cmp(r4, r2);
2211 __ b(eq, &done); 2234 __ b(eq, &done);
2212 __ add(ip, r0, Operand(r4, LSL, kPointerSizeLog2)); 2235 __ add(ip, r0, Operand(r4, LSL, kPointerSizeLog2));
2213 __ ldr(ip, FieldMemOperand(ip, FixedArray::kHeaderSize)); 2236 __ ldr(ip, FieldMemOperand(ip, FixedArray::kHeaderSize));
2237 __ cmp(r5, ip);
2238 __ mov(ip, r6, LeaveCC, eq);
2214 __ Push(ip); 2239 __ Push(ip);
2215 __ add(r4, r4, Operand(1)); 2240 __ add(r4, r4, Operand(1));
2216 __ b(&loop); 2241 __ b(&loop);
2217 __ bind(&done); 2242 __ bind(&done);
2218 __ Move(r0, r4); 2243 __ Move(r0, r4);
2219 } 2244 }
2220 2245
2221 // Dispatch to Call or Construct depending on whether new.target is undefined. 2246 // Dispatch to Call or Construct depending on whether new.target is undefined.
2222 { 2247 {
2223 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); 2248 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex);
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
2868 __ bkpt(0); 2893 __ bkpt(0);
2869 } 2894 }
2870 } 2895 }
2871 2896
2872 #undef __ 2897 #undef __
2873 2898
2874 } // namespace internal 2899 } // namespace internal
2875 } // namespace v8 2900 } // namespace v8
2876 2901
2877 #endif // V8_TARGET_ARCH_ARM 2902 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/builtins/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698