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

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

Issue 1427483002: [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test cleanup 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/heap/heap.cc ('k') | src/mips/builtins-mips.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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 // Allocate the new receiver object using the runtime call. 274 // Allocate the new receiver object using the runtime call.
275 // edx: original constructor 275 // edx: original constructor
276 __ bind(&rt_call); 276 __ bind(&rt_call);
277 int offset = kPointerSize; 277 int offset = kPointerSize;
278 278
279 // Must restore esi (context) and edi (constructor) before calling 279 // Must restore esi (context) and edi (constructor) before calling
280 // runtime. 280 // runtime.
281 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 281 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
282 __ mov(edi, Operand(esp, offset)); 282 __ mov(edi, Operand(esp, offset));
283 __ push(edi); // argument 2/1: constructor function 283 __ push(edi); // constructor function
284 __ push(edx); // argument 3/2: original constructor 284 __ push(edx); // original constructor
285 __ CallRuntime(Runtime::kNewObject, 2); 285 __ CallRuntime(Runtime::kNewObject, 2);
286 __ mov(ebx, eax); // store result in ebx 286 __ mov(ebx, eax); // store result in ebx
287 287
288 // New object allocated. 288 // New object allocated.
289 // ebx: newly allocated object 289 // ebx: newly allocated object
290 __ bind(&allocated); 290 __ bind(&allocated);
291 291
292 // Restore the parameters. 292 // Restore the parameters.
293 __ pop(edx); // new.target 293 __ pop(edx); // new.target
294 __ pop(edi); // Constructor function. 294 __ pop(edi); // Constructor function.
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); 1354 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1);
1355 } 1355 }
1356 } 1356 }
1357 1357
1358 1358
1359 // static 1359 // static
1360 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { 1360 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
1361 // ----------- S t a t e ------------- 1361 // ----------- S t a t e -------------
1362 // -- eax : number of arguments 1362 // -- eax : number of arguments
1363 // -- edi : constructor function 1363 // -- edi : constructor function
1364 // -- edx : original constructor
1364 // -- esp[0] : return address 1365 // -- esp[0] : return address
1365 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1366 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1366 // -- esp[(argc + 1) * 4] : receiver 1367 // -- esp[(argc + 1) * 4] : receiver
1367 // ----------------------------------- 1368 // -----------------------------------
1368 1369
1369 // 1. Load the first argument into ebx and get rid of the rest (including the 1370 // 1. Load the first argument into ebx and get rid of the rest (including the
1370 // receiver). 1371 // receiver).
1371 { 1372 {
1372 Label no_arguments, done; 1373 Label no_arguments, done;
1373 __ test(eax, eax); 1374 __ test(eax, eax);
1374 __ j(zero, &no_arguments, Label::kNear); 1375 __ j(zero, &no_arguments, Label::kNear);
1375 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); 1376 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0));
1376 __ jmp(&done, Label::kNear); 1377 __ jmp(&done, Label::kNear);
1377 __ bind(&no_arguments); 1378 __ bind(&no_arguments);
1378 __ LoadRoot(ebx, Heap::kempty_stringRootIndex); 1379 __ LoadRoot(ebx, Heap::kempty_stringRootIndex);
1379 __ bind(&done); 1380 __ bind(&done);
1380 __ PopReturnAddressTo(ecx); 1381 __ PopReturnAddressTo(ecx);
1381 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); 1382 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
1382 __ PushReturnAddressFrom(ecx); 1383 __ PushReturnAddressFrom(ecx);
1383 } 1384 }
1384 1385
1385 // 2. Make sure ebx is a string. 1386 // 2. Make sure ebx is a string.
1386 { 1387 {
1387 Label convert, done_convert; 1388 Label convert, done_convert;
1388 __ JumpIfSmi(ebx, &convert, Label::kNear); 1389 __ JumpIfSmi(ebx, &convert, Label::kNear);
1389 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, edx); 1390 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, ecx);
1390 __ j(below, &done_convert); 1391 __ j(below, &done_convert);
1391 __ bind(&convert); 1392 __ bind(&convert);
1392 { 1393 {
1393 FrameScope scope(masm, StackFrame::INTERNAL); 1394 FrameScope scope(masm, StackFrame::INTERNAL);
1394 ToStringStub stub(masm->isolate()); 1395 ToStringStub stub(masm->isolate());
1395 __ Push(edi); 1396 __ Push(edi);
1397 __ Push(edx);
1396 __ Move(eax, ebx); 1398 __ Move(eax, ebx);
1397 __ CallStub(&stub); 1399 __ CallStub(&stub);
1398 __ Move(ebx, eax); 1400 __ Move(ebx, eax);
1401 __ Pop(edx);
1399 __ Pop(edi); 1402 __ Pop(edi);
1400 } 1403 }
1401 __ bind(&done_convert); 1404 __ bind(&done_convert);
1402 } 1405 }
1403 1406
1404 // 3. Allocate a JSValue wrapper for the string. 1407 // 3. Allocate a JSValue wrapper for the string.
1405 { 1408 {
1406 // ----------- S t a t e ------------- 1409 // ----------- S t a t e -------------
1407 // -- ebx : the first argument 1410 // -- ebx : the first argument
1408 // -- edi : constructor function 1411 // -- edi : constructor function
1412 // -- edx : original constructor
1409 // ----------------------------------- 1413 // -----------------------------------
1410 1414
1411 Label allocate, done_allocate; 1415 Label allocate, done_allocate, rt_call;
1416
1417 // Fall back to runtime if the original constructor and constructor differ.
1418 __ cmp(edx, edi);
1419 __ j(not_equal, &rt_call);
1420
1412 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT); 1421 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT);
1413 __ bind(&done_allocate); 1422 __ bind(&done_allocate);
1414 1423
1415 // Initialize the JSValue in eax. 1424 // Initialize the JSValue in eax.
1416 __ LoadGlobalFunctionInitialMap(edi, ecx); 1425 __ LoadGlobalFunctionInitialMap(edi, ecx);
1417 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); 1426 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx);
1418 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), 1427 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
1419 masm->isolate()->factory()->empty_fixed_array()); 1428 masm->isolate()->factory()->empty_fixed_array());
1420 __ mov(FieldOperand(eax, JSObject::kElementsOffset), 1429 __ mov(FieldOperand(eax, JSObject::kElementsOffset),
1421 masm->isolate()->factory()->empty_fixed_array()); 1430 masm->isolate()->factory()->empty_fixed_array());
1422 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); 1431 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx);
1423 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 1432 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
1424 __ Ret(); 1433 __ Ret();
1425 1434
1426 // Fallback to the runtime to allocate in new space. 1435 // Fallback to the runtime to allocate in new space.
1427 __ bind(&allocate); 1436 __ bind(&allocate);
1428 { 1437 {
1429 FrameScope scope(masm, StackFrame::INTERNAL); 1438 FrameScope scope(masm, StackFrame::INTERNAL);
1430 __ Push(ebx); 1439 __ Push(ebx);
1431 __ Push(edi); 1440 __ Push(edi);
1432 __ Push(Smi::FromInt(JSValue::kSize)); 1441 __ Push(Smi::FromInt(JSValue::kSize));
1433 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 1442 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1434 __ Pop(edi); 1443 __ Pop(edi);
1435 __ Pop(ebx); 1444 __ Pop(ebx);
1436 } 1445 }
1437 __ jmp(&done_allocate); 1446 __ jmp(&done_allocate);
1447
1448 // Fallback to the runtime to create new object.
1449 __ bind(&rt_call);
1450 {
1451 FrameScope scope(masm, StackFrame::INTERNAL);
1452 __ Push(ebx);
1453 __ Push(edi);
1454 __ Push(edi); // constructor function
1455 __ Push(edx); // original constructor
1456 __ CallRuntime(Runtime::kNewObject, 2);
1457 __ Pop(edi);
1458 __ Pop(ebx);
1459 }
1460 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx);
1461 __ Ret();
1438 } 1462 }
1439 } 1463 }
1440 1464
1441 1465
1442 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, 1466 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm,
1443 Label* stack_overflow) { 1467 Label* stack_overflow) {
1444 // ----------- S t a t e ------------- 1468 // ----------- S t a t e -------------
1445 // -- eax : actual number of arguments 1469 // -- eax : actual number of arguments
1446 // -- ebx : expected number of arguments 1470 // -- ebx : expected number of arguments
1447 // -- edi : function (passed through to callee) 1471 // -- edi : function (passed through to callee)
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1922
1899 __ bind(&ok); 1923 __ bind(&ok);
1900 __ ret(0); 1924 __ ret(0);
1901 } 1925 }
1902 1926
1903 #undef __ 1927 #undef __
1904 } // namespace internal 1928 } // namespace internal
1905 } // namespace v8 1929 } // namespace v8
1906 1930
1907 #endif // V8_TARGET_ARCH_IA32 1931 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698