OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Load the function from the global context. | 165 // Load the function from the global context. |
166 __ mov(prototype, Operand(prototype, Context::SlotOffset(index))); | 166 __ mov(prototype, Operand(prototype, Context::SlotOffset(index))); |
167 // Load the initial map. The global functions all have initial maps. | 167 // Load the initial map. The global functions all have initial maps. |
168 __ mov(prototype, | 168 __ mov(prototype, |
169 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 169 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
170 // Load the prototype from the initial map. | 170 // Load the prototype from the initial map. |
171 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); | 171 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
172 } | 172 } |
173 | 173 |
174 | 174 |
| 175 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
| 176 MacroAssembler* masm, int index, Register prototype) { |
| 177 // Get the global function with the given index. |
| 178 JSFunction* function = JSFunction::cast(Top::global_context()->get(index)); |
| 179 // Load its initial map. The global functions all have initial maps. |
| 180 __ Set(prototype, Immediate(Handle<Map>(function->initial_map()))); |
| 181 // Load the prototype from the initial map. |
| 182 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); |
| 183 } |
| 184 |
| 185 |
175 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | 186 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
176 Register receiver, | 187 Register receiver, |
177 Register scratch, | 188 Register scratch, |
178 Label* miss_label) { | 189 Label* miss_label) { |
179 // Check that the receiver isn't a smi. | 190 // Check that the receiver isn't a smi. |
180 __ test(receiver, Immediate(kSmiTagMask)); | 191 __ test(receiver, Immediate(kSmiTagMask)); |
181 __ j(zero, miss_label, not_taken); | 192 __ j(zero, miss_label, not_taken); |
182 | 193 |
183 // Check that the object is a JS array. | 194 // Check that the object is a JS array. |
184 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); | 195 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 // -- ... | 1332 // -- ... |
1322 // -- esp[(argc + 1) * 4] : receiver | 1333 // -- esp[(argc + 1) * 4] : receiver |
1323 // ----------------------------------- | 1334 // ----------------------------------- |
1324 | 1335 |
1325 const int argc = arguments().immediate(); | 1336 const int argc = arguments().immediate(); |
1326 | 1337 |
1327 Label miss; | 1338 Label miss; |
1328 Label index_out_of_range; | 1339 Label index_out_of_range; |
1329 | 1340 |
1330 // Check that the maps starting from the prototype haven't changed. | 1341 // Check that the maps starting from the prototype haven't changed. |
1331 GenerateLoadGlobalFunctionPrototype(masm(), | 1342 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1332 Context::STRING_FUNCTION_INDEX, | 1343 Context::STRING_FUNCTION_INDEX, |
1333 eax); | 1344 eax); |
1334 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1345 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1335 ebx, edx, name, &miss); | 1346 ebx, edx, name, &miss); |
1336 | 1347 |
1337 Register receiver = ebx; | 1348 Register receiver = ebx; |
1338 Register index = ecx; | 1349 Register index = ecx; |
1339 Register scratch = edx; | 1350 Register scratch = edx; |
1340 Register result = eax; | 1351 Register result = eax; |
1341 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1352 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1342 if (argc > 0) { | 1353 if (argc > 0) { |
1343 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); | 1354 __ mov(index, Operand(esp, (argc - 0) * kPointerSize)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 // -- ... | 1398 // -- ... |
1388 // -- esp[(argc + 1) * 4] : receiver | 1399 // -- esp[(argc + 1) * 4] : receiver |
1389 // ----------------------------------- | 1400 // ----------------------------------- |
1390 | 1401 |
1391 const int argc = arguments().immediate(); | 1402 const int argc = arguments().immediate(); |
1392 | 1403 |
1393 Label miss; | 1404 Label miss; |
1394 Label index_out_of_range; | 1405 Label index_out_of_range; |
1395 | 1406 |
1396 // Check that the maps starting from the prototype haven't changed. | 1407 // Check that the maps starting from the prototype haven't changed. |
1397 GenerateLoadGlobalFunctionPrototype(masm(), | 1408 GenerateDirectLoadGlobalFunctionPrototype(masm(), |
1398 Context::STRING_FUNCTION_INDEX, | 1409 Context::STRING_FUNCTION_INDEX, |
1399 eax); | 1410 eax); |
1400 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1411 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1401 ebx, edx, name, &miss); | 1412 ebx, edx, name, &miss); |
1402 | 1413 |
1403 Register receiver = eax; | 1414 Register receiver = eax; |
1404 Register index = ecx; | 1415 Register index = ecx; |
1405 Register scratch1 = ebx; | 1416 Register scratch1 = ebx; |
1406 Register scratch2 = edx; | 1417 Register scratch2 = edx; |
1407 Register result = eax; | 1418 Register result = eax; |
1408 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); | 1419 __ mov(receiver, Operand(esp, (argc + 1) * kPointerSize)); |
1409 if (argc > 0) { | 1420 if (argc > 0) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (!function->IsBuiltin()) { | 1529 if (!function->IsBuiltin()) { |
1519 // Calling non-builtins with a value as receiver requires boxing. | 1530 // Calling non-builtins with a value as receiver requires boxing. |
1520 __ jmp(&miss); | 1531 __ jmp(&miss); |
1521 } else { | 1532 } else { |
1522 // Check that the object is a string or a symbol. | 1533 // Check that the object is a string or a symbol. |
1523 __ mov(eax, FieldOperand(edx, HeapObject::kMapOffset)); | 1534 __ mov(eax, FieldOperand(edx, HeapObject::kMapOffset)); |
1524 __ movzx_b(eax, FieldOperand(eax, Map::kInstanceTypeOffset)); | 1535 __ movzx_b(eax, FieldOperand(eax, Map::kInstanceTypeOffset)); |
1525 __ cmp(eax, FIRST_NONSTRING_TYPE); | 1536 __ cmp(eax, FIRST_NONSTRING_TYPE); |
1526 __ j(above_equal, &miss, not_taken); | 1537 __ j(above_equal, &miss, not_taken); |
1527 // Check that the maps starting from the prototype haven't changed. | 1538 // Check that the maps starting from the prototype haven't changed. |
1528 GenerateLoadGlobalFunctionPrototype(masm(), | 1539 GenerateDirectLoadGlobalFunctionPrototype( |
1529 Context::STRING_FUNCTION_INDEX, | 1540 masm(), Context::STRING_FUNCTION_INDEX, eax); |
1530 eax); | |
1531 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1541 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1532 ebx, edx, name, &miss); | 1542 ebx, edx, name, &miss); |
1533 } | 1543 } |
1534 break; | 1544 break; |
1535 | 1545 |
1536 case NUMBER_CHECK: { | 1546 case NUMBER_CHECK: { |
1537 if (!function->IsBuiltin()) { | 1547 if (!function->IsBuiltin()) { |
1538 // Calling non-builtins with a value as receiver requires boxing. | 1548 // Calling non-builtins with a value as receiver requires boxing. |
1539 __ jmp(&miss); | 1549 __ jmp(&miss); |
1540 } else { | 1550 } else { |
1541 Label fast; | 1551 Label fast; |
1542 // Check that the object is a smi or a heap number. | 1552 // Check that the object is a smi or a heap number. |
1543 __ test(edx, Immediate(kSmiTagMask)); | 1553 __ test(edx, Immediate(kSmiTagMask)); |
1544 __ j(zero, &fast, taken); | 1554 __ j(zero, &fast, taken); |
1545 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); | 1555 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, eax); |
1546 __ j(not_equal, &miss, not_taken); | 1556 __ j(not_equal, &miss, not_taken); |
1547 __ bind(&fast); | 1557 __ bind(&fast); |
1548 // Check that the maps starting from the prototype haven't changed. | 1558 // Check that the maps starting from the prototype haven't changed. |
1549 GenerateLoadGlobalFunctionPrototype(masm(), | 1559 GenerateDirectLoadGlobalFunctionPrototype( |
1550 Context::NUMBER_FUNCTION_INDEX, | 1560 masm(), Context::NUMBER_FUNCTION_INDEX, eax); |
1551 eax); | |
1552 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1561 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1553 ebx, edx, name, &miss); | 1562 ebx, edx, name, &miss); |
1554 } | 1563 } |
1555 break; | 1564 break; |
1556 } | 1565 } |
1557 | 1566 |
1558 case BOOLEAN_CHECK: { | 1567 case BOOLEAN_CHECK: { |
1559 if (!function->IsBuiltin()) { | 1568 if (!function->IsBuiltin()) { |
1560 // Calling non-builtins with a value as receiver requires boxing. | 1569 // Calling non-builtins with a value as receiver requires boxing. |
1561 __ jmp(&miss); | 1570 __ jmp(&miss); |
1562 } else { | 1571 } else { |
1563 Label fast; | 1572 Label fast; |
1564 // Check that the object is a boolean. | 1573 // Check that the object is a boolean. |
1565 __ cmp(edx, Factory::true_value()); | 1574 __ cmp(edx, Factory::true_value()); |
1566 __ j(equal, &fast, taken); | 1575 __ j(equal, &fast, taken); |
1567 __ cmp(edx, Factory::false_value()); | 1576 __ cmp(edx, Factory::false_value()); |
1568 __ j(not_equal, &miss, not_taken); | 1577 __ j(not_equal, &miss, not_taken); |
1569 __ bind(&fast); | 1578 __ bind(&fast); |
1570 // Check that the maps starting from the prototype haven't changed. | 1579 // Check that the maps starting from the prototype haven't changed. |
1571 GenerateLoadGlobalFunctionPrototype(masm(), | 1580 GenerateDirectLoadGlobalFunctionPrototype( |
1572 Context::BOOLEAN_FUNCTION_INDEX, | 1581 masm(), Context::BOOLEAN_FUNCTION_INDEX, eax); |
1573 eax); | |
1574 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, | 1582 CheckPrototypes(JSObject::cast(object->GetPrototype()), eax, holder, |
1575 ebx, edx, name, &miss); | 1583 ebx, edx, name, &miss); |
1576 } | 1584 } |
1577 break; | 1585 break; |
1578 } | 1586 } |
1579 | 1587 |
1580 default: | 1588 default: |
1581 UNREACHABLE(); | 1589 UNREACHABLE(); |
1582 } | 1590 } |
1583 | 1591 |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 // Return the generated code. | 2479 // Return the generated code. |
2472 return GetCode(); | 2480 return GetCode(); |
2473 } | 2481 } |
2474 | 2482 |
2475 | 2483 |
2476 #undef __ | 2484 #undef __ |
2477 | 2485 |
2478 } } // namespace v8::internal | 2486 } } // namespace v8::internal |
2479 | 2487 |
2480 #endif // V8_TARGET_ARCH_IA32 | 2488 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |