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

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

Issue 1416943005: Revert of [es6] Better support for built-ins subclassing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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); // constructor function 283 __ push(edi); // argument 2/1: constructor function
284 __ push(edx); // original constructor 284 __ push(edx); // argument 3/2: 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
1365 // -- esp[0] : return address 1364 // -- esp[0] : return address
1366 // -- esp[(argc - n) * 4] : arg[n] (zero-based) 1365 // -- esp[(argc - n) * 4] : arg[n] (zero-based)
1367 // -- esp[(argc + 1) * 4] : receiver 1366 // -- esp[(argc + 1) * 4] : receiver
1368 // ----------------------------------- 1367 // -----------------------------------
1369 1368
1370 // 1. Load the first argument into ebx and get rid of the rest (including the 1369 // 1. Load the first argument into ebx and get rid of the rest (including the
1371 // receiver). 1370 // receiver).
1372 { 1371 {
1373 Label no_arguments, done; 1372 Label no_arguments, done;
1374 __ test(eax, eax); 1373 __ test(eax, eax);
1375 __ j(zero, &no_arguments, Label::kNear); 1374 __ j(zero, &no_arguments, Label::kNear);
1376 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0)); 1375 __ mov(ebx, Operand(esp, eax, times_pointer_size, 0));
1377 __ jmp(&done, Label::kNear); 1376 __ jmp(&done, Label::kNear);
1378 __ bind(&no_arguments); 1377 __ bind(&no_arguments);
1379 __ LoadRoot(ebx, Heap::kempty_stringRootIndex); 1378 __ LoadRoot(ebx, Heap::kempty_stringRootIndex);
1380 __ bind(&done); 1379 __ bind(&done);
1381 __ PopReturnAddressTo(ecx); 1380 __ PopReturnAddressTo(ecx);
1382 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize)); 1381 __ lea(esp, Operand(esp, eax, times_pointer_size, kPointerSize));
1383 __ PushReturnAddressFrom(ecx); 1382 __ PushReturnAddressFrom(ecx);
1384 } 1383 }
1385 1384
1386 // 2. Make sure ebx is a string. 1385 // 2. Make sure ebx is a string.
1387 { 1386 {
1388 Label convert, done_convert; 1387 Label convert, done_convert;
1389 __ JumpIfSmi(ebx, &convert, Label::kNear); 1388 __ JumpIfSmi(ebx, &convert, Label::kNear);
1390 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, ecx); 1389 __ CmpObjectType(ebx, FIRST_NONSTRING_TYPE, edx);
1391 __ j(below, &done_convert); 1390 __ j(below, &done_convert);
1392 __ bind(&convert); 1391 __ bind(&convert);
1393 { 1392 {
1394 FrameScope scope(masm, StackFrame::INTERNAL); 1393 FrameScope scope(masm, StackFrame::INTERNAL);
1395 ToStringStub stub(masm->isolate()); 1394 ToStringStub stub(masm->isolate());
1396 __ Push(edi); 1395 __ Push(edi);
1397 __ Push(edx);
1398 __ Move(eax, ebx); 1396 __ Move(eax, ebx);
1399 __ CallStub(&stub); 1397 __ CallStub(&stub);
1400 __ Move(ebx, eax); 1398 __ Move(ebx, eax);
1401 __ Pop(edx);
1402 __ Pop(edi); 1399 __ Pop(edi);
1403 } 1400 }
1404 __ bind(&done_convert); 1401 __ bind(&done_convert);
1405 } 1402 }
1406 1403
1407 // 3. Allocate a JSValue wrapper for the string. 1404 // 3. Allocate a JSValue wrapper for the string.
1408 { 1405 {
1409 // ----------- S t a t e ------------- 1406 // ----------- S t a t e -------------
1410 // -- ebx : the first argument 1407 // -- ebx : the first argument
1411 // -- edi : constructor function 1408 // -- edi : constructor function
1412 // -- edx : original constructor
1413 // ----------------------------------- 1409 // -----------------------------------
1414 1410
1415 Label allocate, done_allocate, rt_call; 1411 Label allocate, done_allocate;
1416
1417 // Fall back to runtime if the original constructor and constructor differ.
1418 __ cmp(edx, edi);
1419 __ j(not_equal, &rt_call);
1420
1421 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT); 1412 __ Allocate(JSValue::kSize, eax, ecx, no_reg, &allocate, TAG_OBJECT);
1422 __ bind(&done_allocate); 1413 __ bind(&done_allocate);
1423 1414
1424 // Initialize the JSValue in eax. 1415 // Initialize the JSValue in eax.
1425 __ LoadGlobalFunctionInitialMap(edi, ecx); 1416 __ LoadGlobalFunctionInitialMap(edi, ecx);
1426 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx); 1417 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ecx);
1427 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), 1418 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
1428 masm->isolate()->factory()->empty_fixed_array()); 1419 masm->isolate()->factory()->empty_fixed_array());
1429 __ mov(FieldOperand(eax, JSObject::kElementsOffset), 1420 __ mov(FieldOperand(eax, JSObject::kElementsOffset),
1430 masm->isolate()->factory()->empty_fixed_array()); 1421 masm->isolate()->factory()->empty_fixed_array());
1431 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx); 1422 __ mov(FieldOperand(eax, JSValue::kValueOffset), ebx);
1432 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); 1423 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize);
1433 __ Ret(); 1424 __ Ret();
1434 1425
1435 // Fallback to the runtime to allocate in new space. 1426 // Fallback to the runtime to allocate in new space.
1436 __ bind(&allocate); 1427 __ bind(&allocate);
1437 { 1428 {
1438 FrameScope scope(masm, StackFrame::INTERNAL); 1429 FrameScope scope(masm, StackFrame::INTERNAL);
1439 __ Push(ebx); 1430 __ Push(ebx);
1440 __ Push(edi); 1431 __ Push(edi);
1441 __ Push(Smi::FromInt(JSValue::kSize)); 1432 __ Push(Smi::FromInt(JSValue::kSize));
1442 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); 1433 __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1443 __ Pop(edi); 1434 __ Pop(edi);
1444 __ Pop(ebx); 1435 __ Pop(ebx);
1445 } 1436 }
1446 __ jmp(&done_allocate); 1437 __ 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();
1462 } 1438 }
1463 } 1439 }
1464 1440
1465 1441
1466 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, 1442 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm,
1467 Label* stack_overflow) { 1443 Label* stack_overflow) {
1468 // ----------- S t a t e ------------- 1444 // ----------- S t a t e -------------
1469 // -- eax : actual number of arguments 1445 // -- eax : actual number of arguments
1470 // -- ebx : expected number of arguments 1446 // -- ebx : expected number of arguments
1471 // -- edi : function (passed through to callee) 1447 // -- edi : function (passed through to callee)
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 1898
1923 __ bind(&ok); 1899 __ bind(&ok);
1924 __ ret(0); 1900 __ ret(0);
1925 } 1901 }
1926 1902
1927 #undef __ 1903 #undef __
1928 } // namespace internal 1904 } // namespace internal
1929 } // namespace v8 1905 } // namespace v8
1930 1906
1931 #endif // V8_TARGET_ARCH_IA32 1907 #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