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

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

Issue 1413033006: Reland "[es6] Better support for built-ins subclassing." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: We don't need TypedArray map smashing anymore Created 5 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
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/crankshaft/hydrogen.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); 202 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
203 } 203 }
204 } 204 }
205 205
206 206
207 // static 207 // static
208 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { 208 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
209 // ----------- S t a t e ------------- 209 // ----------- S t a t e -------------
210 // -- x0 : number of arguments 210 // -- x0 : number of arguments
211 // -- x1 : constructor function 211 // -- x1 : constructor function
212 // -- x3 : original constructor
212 // -- lr : return address 213 // -- lr : return address
213 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) 214 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based)
214 // -- sp[argc * 8] : receiver 215 // -- sp[argc * 8] : receiver
215 // ----------------------------------- 216 // -----------------------------------
216 ASM_LOCATION("Builtins::Generate_StringConstructor_ConstructStub"); 217 ASM_LOCATION("Builtins::Generate_StringConstructor_ConstructStub");
217 218
218 // 1. Load the first argument into x2 and get rid of the rest (including the 219 // 1. Load the first argument into x2 and get rid of the rest (including the
219 // receiver). 220 // receiver).
220 { 221 {
221 Label no_arguments, done; 222 Label no_arguments, done;
222 __ Cbz(x0, &no_arguments); 223 __ Cbz(x0, &no_arguments);
223 __ Sub(x0, x0, 1); 224 __ Sub(x0, x0, 1);
224 __ Drop(x0); 225 __ Drop(x0);
225 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex)); 226 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex));
226 __ B(&done); 227 __ B(&done);
227 __ Bind(&no_arguments); 228 __ Bind(&no_arguments);
228 __ Drop(1); 229 __ Drop(1);
229 __ LoadRoot(x2, Heap::kempty_stringRootIndex); 230 __ LoadRoot(x2, Heap::kempty_stringRootIndex);
230 __ Bind(&done); 231 __ Bind(&done);
231 } 232 }
232 233
233 // 2. Make sure x2 is a string. 234 // 2. Make sure x2 is a string.
234 { 235 {
235 Label convert, done_convert; 236 Label convert, done_convert;
236 __ JumpIfSmi(x2, &convert); 237 __ JumpIfSmi(x2, &convert);
237 __ JumpIfObjectType(x2, x3, x3, FIRST_NONSTRING_TYPE, &done_convert, lo); 238 __ JumpIfObjectType(x2, x4, x4, FIRST_NONSTRING_TYPE, &done_convert, lo);
238 __ Bind(&convert); 239 __ Bind(&convert);
239 { 240 {
240 FrameScope scope(masm, StackFrame::INTERNAL); 241 FrameScope scope(masm, StackFrame::INTERNAL);
241 ToStringStub stub(masm->isolate()); 242 ToStringStub stub(masm->isolate());
242 __ Push(x1); 243 __ Push(x1, x3);
243 __ Move(x0, x2); 244 __ Move(x0, x2);
244 __ CallStub(&stub); 245 __ CallStub(&stub);
245 __ Move(x2, x0); 246 __ Move(x2, x0);
246 __ Pop(x1); 247 __ Pop(x1, x3);
247 } 248 }
248 __ Bind(&done_convert); 249 __ Bind(&done_convert);
249 } 250 }
250 251
251 // 3. Allocate a JSValue wrapper for the string. 252 // 3. Allocate a JSValue wrapper for the string.
252 { 253 {
253 // ----------- S t a t e ------------- 254 // ----------- S t a t e -------------
255 // -- x2 : the first argument
254 // -- x1 : constructor function 256 // -- x1 : constructor function
255 // -- x2 : the first argument 257 // -- x3 : original constructor
256 // -- lr : return address 258 // -- lr : return address
257 // ----------------------------------- 259 // -----------------------------------
258 260
259 Label allocate, done_allocate; 261 Label allocate, done_allocate, rt_call;
262
263 // Fall back to runtime if the original constructor and function differ.
264 __ cmp(x1, x3);
265 __ B(ne, &rt_call);
266
260 __ Allocate(JSValue::kSize, x0, x3, x4, &allocate, TAG_OBJECT); 267 __ Allocate(JSValue::kSize, x0, x3, x4, &allocate, TAG_OBJECT);
261 __ Bind(&done_allocate); 268 __ Bind(&done_allocate);
262 269
263 // Initialize the JSValue in eax. 270 // Initialize the JSValue in eax.
264 __ LoadGlobalFunctionInitialMap(x1, x3, x4); 271 __ LoadGlobalFunctionInitialMap(x1, x3, x4);
265 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset)); 272 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset));
266 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); 273 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex);
267 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); 274 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset));
268 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); 275 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset));
269 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); 276 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset));
270 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 277 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
271 __ Ret(); 278 __ Ret();
272 279
273 // Fallback to the runtime to allocate in new space. 280 // Fallback to the runtime to allocate in new space.
274 __ Bind(&allocate); 281 __ Bind(&allocate);
275 { 282 {
276 FrameScope scope(masm, StackFrame::INTERNAL); 283 FrameScope scope(masm, StackFrame::INTERNAL);
277 __ Push(x1, x2); 284 __ Push(x1, x2);
278 __ Push(Smi::FromInt(JSValue::kSize)); 285 __ Push(Smi::FromInt(JSValue::kSize));
279 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 286 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
280 __ Pop(x2, x1); 287 __ Pop(x2, x1);
281 } 288 }
282 __ B(&done_allocate); 289 __ B(&done_allocate);
290
291 // Fallback to the runtime to create new object.
292 __ bind(&rt_call);
293 {
294 FrameScope scope(masm, StackFrame::INTERNAL);
295 __ Push(x1, x2, x1, x3); // constructor function, original constructor
296 __ CallRuntime(Runtime::kNewObject, 2);
297 __ Pop(x2, x1);
298 }
299 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset));
300 __ Ret();
283 } 301 }
284 } 302 }
285 303
286 304
287 static void CallRuntimePassFunction(MacroAssembler* masm, 305 static void CallRuntimePassFunction(MacroAssembler* masm,
288 Runtime::FunctionId function_id) { 306 Runtime::FunctionId function_id) {
289 FrameScope scope(masm, StackFrame::INTERNAL); 307 FrameScope scope(masm, StackFrame::INTERNAL);
290 // - Push a copy of the function onto the stack. 308 // - Push a copy of the function onto the stack.
291 // - Push another copy as a parameter to the runtime call. 309 // - Push another copy as a parameter to the runtime call.
292 __ Push(x1, x1); 310 __ Push(x1, x1);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 GenerateTailCallToSharedCode(masm); 347 GenerateTailCallToSharedCode(masm);
330 } 348 }
331 349
332 350
333 static void Generate_JSConstructStubHelper(MacroAssembler* masm, 351 static void Generate_JSConstructStubHelper(MacroAssembler* masm,
334 bool is_api_function) { 352 bool is_api_function) {
335 // ----------- S t a t e ------------- 353 // ----------- S t a t e -------------
336 // -- x0 : number of arguments 354 // -- x0 : number of arguments
337 // -- x1 : constructor function 355 // -- x1 : constructor function
338 // -- x2 : allocation site or undefined 356 // -- x2 : allocation site or undefined
339 // -- x3 : original constructor 357 // -- x3 : original constructor
340 // -- lr : return address 358 // -- lr : return address
341 // -- sp[...]: constructor arguments 359 // -- sp[...]: constructor arguments
342 // ----------------------------------- 360 // -----------------------------------
343 361
344 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper"); 362 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper");
345 363
346 Isolate* isolate = masm->isolate(); 364 Isolate* isolate = masm->isolate();
347 365
348 // Enter a construct frame. 366 // Enter a construct frame.
349 { 367 {
(...skipping 1639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 } 2007 }
1990 } 2008 }
1991 2009
1992 2010
1993 #undef __ 2011 #undef __
1994 2012
1995 } // namespace internal 2013 } // namespace internal
1996 } // namespace v8 2014 } // namespace v8
1997 2015
1998 #endif // V8_TARGET_ARCH_ARM 2016 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698