OLD | NEW |
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_S390 | 5 #if V8_TARGET_ARCH_S390 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 // 31bit ABI requires you to store f4 and f6: | 1360 // 31bit ABI requires you to store f4 and f6: |
1361 // http://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_s390.html#AEN417 | 1361 // http://refspecs.linuxbase.org/ELF/zSeries/lzsabi0_s390.html#AEN417 |
1362 __ ld(d4, MemOperand(sp)); | 1362 __ ld(d4, MemOperand(sp)); |
1363 __ ld(d6, MemOperand(sp, kDoubleSize)); | 1363 __ ld(d6, MemOperand(sp, kDoubleSize)); |
1364 __ la(sp, MemOperand(sp, 2 * kDoubleSize)); | 1364 __ la(sp, MemOperand(sp, 2 * kDoubleSize)); |
1365 #endif | 1365 #endif |
1366 | 1366 |
1367 __ b(r14); | 1367 __ b(r14); |
1368 } | 1368 } |
1369 | 1369 |
1370 void InstanceOfStub::Generate(MacroAssembler* masm) { | |
1371 Register const object = r3; // Object (lhs). | |
1372 Register const function = r2; // Function (rhs). | |
1373 Register const object_map = r4; // Map of {object}. | |
1374 Register const function_map = r5; // Map of {function}. | |
1375 Register const function_prototype = r6; // Prototype of {function}. | |
1376 Register const scratch = r7; | |
1377 | |
1378 DCHECK(object.is(InstanceOfDescriptor::LeftRegister())); | |
1379 DCHECK(function.is(InstanceOfDescriptor::RightRegister())); | |
1380 | |
1381 // Check if {object} is a smi. | |
1382 Label object_is_smi; | |
1383 __ JumpIfSmi(object, &object_is_smi); | |
1384 | |
1385 // Lookup the {function} and the {object} map in the global instanceof cache. | |
1386 // Note: This is safe because we clear the global instanceof cache whenever | |
1387 // we change the prototype of any object. | |
1388 Label fast_case, slow_case; | |
1389 __ LoadP(object_map, FieldMemOperand(object, HeapObject::kMapOffset)); | |
1390 __ CompareRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | |
1391 __ bne(&fast_case); | |
1392 __ CompareRoot(object_map, Heap::kInstanceofCacheMapRootIndex); | |
1393 __ bne(&fast_case); | |
1394 __ LoadRoot(r2, Heap::kInstanceofCacheAnswerRootIndex); | |
1395 __ Ret(); | |
1396 | |
1397 // If {object} is a smi we can safely return false if {function} is a JS | |
1398 // function, otherwise we have to miss to the runtime and throw an exception. | |
1399 __ bind(&object_is_smi); | |
1400 __ JumpIfSmi(function, &slow_case); | |
1401 __ CompareObjectType(function, function_map, scratch, JS_FUNCTION_TYPE); | |
1402 __ bne(&slow_case); | |
1403 __ LoadRoot(r2, Heap::kFalseValueRootIndex); | |
1404 __ Ret(); | |
1405 | |
1406 // Fast-case: The {function} must be a valid JSFunction. | |
1407 __ bind(&fast_case); | |
1408 __ JumpIfSmi(function, &slow_case); | |
1409 __ CompareObjectType(function, function_map, scratch, JS_FUNCTION_TYPE); | |
1410 __ bne(&slow_case); | |
1411 | |
1412 // Go to the runtime if the function is not a constructor. | |
1413 __ LoadlB(scratch, FieldMemOperand(function_map, Map::kBitFieldOffset)); | |
1414 __ TestBit(scratch, Map::kIsConstructor, r0); | |
1415 __ beq(&slow_case); | |
1416 | |
1417 // Ensure that {function} has an instance prototype. | |
1418 __ TestBit(scratch, Map::kHasNonInstancePrototype, r0); | |
1419 __ bne(&slow_case); | |
1420 | |
1421 // Get the "prototype" (or initial map) of the {function}. | |
1422 __ LoadP(function_prototype, | |
1423 FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | |
1424 __ AssertNotSmi(function_prototype); | |
1425 | |
1426 // Resolve the prototype if the {function} has an initial map. Afterwards the | |
1427 // {function_prototype} will be either the JSReceiver prototype object or the | |
1428 // hole value, which means that no instances of the {function} were created so | |
1429 // far and hence we should return false. | |
1430 Label function_prototype_valid; | |
1431 __ CompareObjectType(function_prototype, scratch, scratch, MAP_TYPE); | |
1432 __ bne(&function_prototype_valid); | |
1433 __ LoadP(function_prototype, | |
1434 FieldMemOperand(function_prototype, Map::kPrototypeOffset)); | |
1435 __ bind(&function_prototype_valid); | |
1436 __ AssertNotSmi(function_prototype); | |
1437 | |
1438 // Update the global instanceof cache with the current {object} map and | |
1439 // {function}. The cached answer will be set when it is known below. | |
1440 __ StoreRoot(function, Heap::kInstanceofCacheFunctionRootIndex); | |
1441 __ StoreRoot(object_map, Heap::kInstanceofCacheMapRootIndex); | |
1442 | |
1443 // Loop through the prototype chain looking for the {function} prototype. | |
1444 // Assume true, and change to false if not found. | |
1445 Register const object_instance_type = function_map; | |
1446 Register const map_bit_field = function_map; | |
1447 Register const null = scratch; | |
1448 Register const result = r2; | |
1449 | |
1450 Label done, loop, fast_runtime_fallback; | |
1451 __ LoadRoot(result, Heap::kTrueValueRootIndex); | |
1452 __ LoadRoot(null, Heap::kNullValueRootIndex); | |
1453 __ bind(&loop); | |
1454 | |
1455 // Check if the object needs to be access checked. | |
1456 __ LoadlB(map_bit_field, FieldMemOperand(object_map, Map::kBitFieldOffset)); | |
1457 __ TestBit(map_bit_field, Map::kIsAccessCheckNeeded, r0); | |
1458 __ bne(&fast_runtime_fallback); | |
1459 // Check if the current object is a Proxy. | |
1460 __ CompareInstanceType(object_map, object_instance_type, JS_PROXY_TYPE); | |
1461 __ beq(&fast_runtime_fallback); | |
1462 | |
1463 __ LoadP(object, FieldMemOperand(object_map, Map::kPrototypeOffset)); | |
1464 __ CmpP(object, function_prototype); | |
1465 __ beq(&done); | |
1466 __ CmpP(object, null); | |
1467 __ LoadP(object_map, FieldMemOperand(object, HeapObject::kMapOffset)); | |
1468 __ bne(&loop); | |
1469 __ LoadRoot(result, Heap::kFalseValueRootIndex); | |
1470 __ bind(&done); | |
1471 __ StoreRoot(result, Heap::kInstanceofCacheAnswerRootIndex); | |
1472 __ Ret(); | |
1473 | |
1474 // Found Proxy or access check needed: Call the runtime | |
1475 __ bind(&fast_runtime_fallback); | |
1476 __ Push(object, function_prototype); | |
1477 // Invalidate the instanceof cache. | |
1478 __ LoadSmiLiteral(scratch, Smi::FromInt(0)); | |
1479 __ StoreRoot(scratch, Heap::kInstanceofCacheFunctionRootIndex); | |
1480 __ TailCallRuntime(Runtime::kHasInPrototypeChain); | |
1481 | |
1482 // Slow-case: Call the %InstanceOf runtime function. | |
1483 __ bind(&slow_case); | |
1484 __ Push(object, function); | |
1485 __ TailCallRuntime(is_es6_instanceof() ? Runtime::kOrdinaryHasInstance | |
1486 : Runtime::kInstanceOf); | |
1487 } | |
1488 | |
1489 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { | 1370 void FunctionPrototypeStub::Generate(MacroAssembler* masm) { |
1490 Label miss; | 1371 Label miss; |
1491 Register receiver = LoadDescriptor::ReceiverRegister(); | 1372 Register receiver = LoadDescriptor::ReceiverRegister(); |
1492 // Ensure that the vector and slot registers won't be clobbered before | 1373 // Ensure that the vector and slot registers won't be clobbered before |
1493 // calling the miss handler. | 1374 // calling the miss handler. |
1494 DCHECK(!AreAliased(r6, r7, LoadWithVectorDescriptor::VectorRegister(), | 1375 DCHECK(!AreAliased(r6, r7, LoadWithVectorDescriptor::VectorRegister(), |
1495 LoadWithVectorDescriptor::SlotRegister())); | 1376 LoadWithVectorDescriptor::SlotRegister())); |
1496 | 1377 |
1497 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r6, | 1378 NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(masm, receiver, r6, |
1498 r7, &miss); | 1379 r7, &miss); |
(...skipping 4215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5714 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5595 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5715 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5596 kStackUnwindSpace, NULL, return_value_operand, NULL); |
5716 } | 5597 } |
5717 | 5598 |
5718 #undef __ | 5599 #undef __ |
5719 | 5600 |
5720 } // namespace internal | 5601 } // namespace internal |
5721 } // namespace v8 | 5602 } // namespace v8 |
5722 | 5603 |
5723 #endif // V8_TARGET_ARCH_S390 | 5604 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |