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

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

Issue 2566793002: PPC/s390: [x86] Also deal with holey arrays 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/s390/builtins-s390.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2156 void Builtins::Generate_Apply(MacroAssembler* masm) { 2156 void Builtins::Generate_Apply(MacroAssembler* masm) {
2157 // ----------- S t a t e ------------- 2157 // ----------- S t a t e -------------
2158 // -- r3 : argumentsList 2158 // -- r3 : argumentsList
2159 // -- r4 : target 2159 // -- r4 : target
2160 // -- r6 : new.target (checked to be constructor or undefined) 2160 // -- r6 : new.target (checked to be constructor or undefined)
2161 // -- sp[0] : thisArgument 2161 // -- sp[0] : thisArgument
2162 // ----------------------------------- 2162 // -----------------------------------
2163 2163
2164 // Create the list of arguments from the array-like argumentsList. 2164 // Create the list of arguments from the array-like argumentsList.
2165 { 2165 {
2166 Label create_arguments, create_array, create_runtime, done_create; 2166 Label create_arguments, create_array, create_holey_array, create_runtime,
2167 done_create;
2167 __ JumpIfSmi(r3, &create_runtime); 2168 __ JumpIfSmi(r3, &create_runtime);
2168 2169
2169 // Load the map of argumentsList into r5. 2170 // Load the map of argumentsList into r5.
2170 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset)); 2171 __ LoadP(r5, FieldMemOperand(r3, HeapObject::kMapOffset));
2171 2172
2172 // Load native context into r7. 2173 // Load native context into r7.
2173 __ LoadP(r7, NativeContextMemOperand()); 2174 __ LoadP(r7, NativeContextMemOperand());
2174 2175
2175 // Check if argumentsList is an (unmodified) arguments object. 2176 // Check if argumentsList is an (unmodified) arguments object.
2176 __ LoadP(ip, ContextMemOperand(r7, Context::SLOPPY_ARGUMENTS_MAP_INDEX)); 2177 __ LoadP(ip, ContextMemOperand(r7, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
(...skipping 23 matching lines...) Expand all
2200 __ bind(&create_arguments); 2201 __ bind(&create_arguments);
2201 __ LoadP(r5, FieldMemOperand(r3, JSArgumentsObject::kLengthOffset)); 2202 __ LoadP(r5, FieldMemOperand(r3, JSArgumentsObject::kLengthOffset));
2202 __ LoadP(r7, FieldMemOperand(r3, JSObject::kElementsOffset)); 2203 __ LoadP(r7, FieldMemOperand(r3, JSObject::kElementsOffset));
2203 __ LoadP(ip, FieldMemOperand(r7, FixedArray::kLengthOffset)); 2204 __ LoadP(ip, FieldMemOperand(r7, FixedArray::kLengthOffset));
2204 __ cmp(r5, ip); 2205 __ cmp(r5, ip);
2205 __ bne(&create_runtime); 2206 __ bne(&create_runtime);
2206 __ SmiUntag(r5); 2207 __ SmiUntag(r5);
2207 __ mr(r3, r7); 2208 __ mr(r3, r7);
2208 __ b(&done_create); 2209 __ b(&done_create);
2209 2210
2211 // For holey JSArrays we need to check that the array prototype chain
2212 // protector is intact and our prototype is the Array.prototype actually.
2213 __ bind(&create_holey_array);
2214 __ LoadP(r5, FieldMemOperand(r5, Map::kPrototypeOffset));
2215 __ LoadP(r7, ContextMemOperand(r7, Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
2216 __ cmp(r5, r7);
2217 __ bne(&create_runtime);
2218 __ LoadRoot(r7, Heap::kArrayProtectorRootIndex);
2219 __ LoadP(r5, FieldMemOperand(r7, PropertyCell::kValueOffset));
2220 __ CmpSmiLiteral(r5, Smi::FromInt(Isolate::kProtectorValid), r0);
2221 __ bne(&create_runtime);
2222 __ LoadP(r5, FieldMemOperand(r3, JSArray::kLengthOffset));
2223 __ LoadP(r3, FieldMemOperand(r3, JSArray::kElementsOffset));
2224 __ SmiUntag(r5);
2225 __ b(&done_create);
2226
2210 // Try to create the list from a JSArray object. 2227 // Try to create the list from a JSArray object.
2228 // -- r5 and r7 must be preserved till bne create_holey_array.
2211 __ bind(&create_array); 2229 __ bind(&create_array);
2212 __ lbz(r5, FieldMemOperand(r5, Map::kBitField2Offset)); 2230 __ lbz(r8, FieldMemOperand(r5, Map::kBitField2Offset));
2213 __ DecodeField<Map::ElementsKindBits>(r5); 2231 __ DecodeField<Map::ElementsKindBits>(r8);
2214 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); 2232 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0);
2215 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); 2233 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1);
2216 STATIC_ASSERT(FAST_ELEMENTS == 2); 2234 STATIC_ASSERT(FAST_ELEMENTS == 2);
2217 __ cmpi(r5, Operand(FAST_ELEMENTS)); 2235 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3);
2236 __ cmpi(r8, Operand(FAST_HOLEY_ELEMENTS));
2218 __ bgt(&create_runtime); 2237 __ bgt(&create_runtime);
2219 __ cmpi(r5, Operand(FAST_HOLEY_SMI_ELEMENTS)); 2238 // Only FAST_XXX after this point, FAST_HOLEY_XXX are odd values.
2220 __ beq(&create_runtime); 2239 __ TestBit(r8, Map::kHasNonInstancePrototype, r0);
2240 __ bne(&create_holey_array, cr0);
2241 // FAST_SMI_ELEMENTS or FAST_ELEMENTS after this point.
2221 __ LoadP(r5, FieldMemOperand(r3, JSArray::kLengthOffset)); 2242 __ LoadP(r5, FieldMemOperand(r3, JSArray::kLengthOffset));
2222 __ LoadP(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); 2243 __ LoadP(r3, FieldMemOperand(r3, JSArray::kElementsOffset));
2223 __ SmiUntag(r5); 2244 __ SmiUntag(r5);
2224 2245
2225 __ bind(&done_create); 2246 __ bind(&done_create);
2226 } 2247 }
2227 2248
2228 // Check for stack overflow. 2249 // Check for stack overflow.
2229 { 2250 {
2230 // Check the stack for overflow. We are not trying to catch interruptions 2251 // Check the stack for overflow. We are not trying to catch interruptions
(...skipping 14 matching lines...) Expand all
2245 // ----------- S t a t e ------------- 2266 // ----------- S t a t e -------------
2246 // -- r4 : target 2267 // -- r4 : target
2247 // -- r3 : args (a FixedArray built from argumentsList) 2268 // -- r3 : args (a FixedArray built from argumentsList)
2248 // -- r5 : len (number of elements to push from args) 2269 // -- r5 : len (number of elements to push from args)
2249 // -- r6 : new.target (checked to be constructor or undefined) 2270 // -- r6 : new.target (checked to be constructor or undefined)
2250 // -- sp[0] : thisArgument 2271 // -- sp[0] : thisArgument
2251 // ----------------------------------- 2272 // -----------------------------------
2252 2273
2253 // Push arguments onto the stack (thisArgument is already on the stack). 2274 // Push arguments onto the stack (thisArgument is already on the stack).
2254 { 2275 {
2255 Label loop, no_args; 2276 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex);
2277 Label loop, no_args, skip;
2256 __ cmpi(r5, Operand::Zero()); 2278 __ cmpi(r5, Operand::Zero());
2257 __ beq(&no_args); 2279 __ beq(&no_args);
2258 __ addi(r3, r3, 2280 __ addi(r3, r3,
2259 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize)); 2281 Operand(FixedArray::kHeaderSize - kHeapObjectTag - kPointerSize));
2260 __ mtctr(r5); 2282 __ mtctr(r5);
2261 __ bind(&loop); 2283 __ bind(&loop);
2262 __ LoadPU(r0, MemOperand(r3, kPointerSize)); 2284 __ LoadPU(ip, MemOperand(r3, kPointerSize));
2263 __ push(r0); 2285 __ CompareRoot(ip, Heap::kTheHoleValueRootIndex);
2286 __ bne(&skip);
2287 __ mr(ip, r9);
2288 __ bind(&skip);
2289 __ push(ip);
2264 __ bdnz(&loop); 2290 __ bdnz(&loop);
2265 __ bind(&no_args); 2291 __ bind(&no_args);
2266 __ mr(r3, r5); 2292 __ mr(r3, r5);
2267 } 2293 }
2268 2294
2269 // Dispatch to Call or Construct depending on whether new.target is undefined. 2295 // Dispatch to Call or Construct depending on whether new.target is undefined.
2270 { 2296 {
2271 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex); 2297 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex);
2272 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); 2298 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq);
2273 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 2299 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2945 __ CallRuntime(Runtime::kThrowStackOverflow); 2971 __ CallRuntime(Runtime::kThrowStackOverflow);
2946 __ bkpt(0); 2972 __ bkpt(0);
2947 } 2973 }
2948 } 2974 }
2949 2975
2950 #undef __ 2976 #undef __
2951 } // namespace internal 2977 } // namespace internal
2952 } // namespace v8 2978 } // namespace v8
2953 2979
2954 #endif // V8_TARGET_ARCH_PPC 2980 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | src/builtins/s390/builtins-s390.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698