| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 | 1414 |
| 1415 // After this, registers are used as follows: | 1415 // After this, registers are used as follows: |
| 1416 // v0: Newly allocated regexp. | 1416 // v0: Newly allocated regexp. |
| 1417 // t1: Materialized regexp. | 1417 // t1: Materialized regexp. |
| 1418 // a2: temp. | 1418 // a2: temp. |
| 1419 __ CopyFields(v0, t1, a2.bit(), size / kPointerSize); | 1419 __ CopyFields(v0, t1, a2.bit(), size / kPointerSize); |
| 1420 context()->Plug(v0); | 1420 context()->Plug(v0); |
| 1421 } | 1421 } |
| 1422 | 1422 |
| 1423 | 1423 |
| 1424 void FullCodeGenerator::EmitAccessor(Expression* expression) { |
| 1425 if (expression == NULL) { |
| 1426 __ LoadRoot(a1, Heap::kNullValueRootIndex); |
| 1427 __ push(a1); |
| 1428 } else { |
| 1429 VisitForStackValue(expression); |
| 1430 } |
| 1431 } |
| 1432 |
| 1433 |
| 1424 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1434 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1425 Comment cmnt(masm_, "[ ObjectLiteral"); | 1435 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1426 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1436 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1427 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1437 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1428 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 1438 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
| 1429 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); | 1439 __ li(a2, Operand(Smi::FromInt(expr->literal_index()))); |
| 1430 __ li(a1, Operand(constant_properties)); | 1440 __ li(a1, Operand(constant_properties)); |
| 1431 int flags = expr->fast_elements() | 1441 int flags = expr->fast_elements() |
| 1432 ? ObjectLiteral::kFastElements | 1442 ? ObjectLiteral::kFastElements |
| 1433 : ObjectLiteral::kNoFlags; | 1443 : ObjectLiteral::kNoFlags; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1449 | 1459 |
| 1450 // If result_saved is true the result is on top of the stack. If | 1460 // If result_saved is true the result is on top of the stack. If |
| 1451 // result_saved is false the result is in v0. | 1461 // result_saved is false the result is in v0. |
| 1452 bool result_saved = false; | 1462 bool result_saved = false; |
| 1453 | 1463 |
| 1454 // Mark all computed expressions that are bound to a key that | 1464 // Mark all computed expressions that are bound to a key that |
| 1455 // is shadowed by a later occurrence of the same key. For the | 1465 // is shadowed by a later occurrence of the same key. For the |
| 1456 // marked expressions, no store code is emitted. | 1466 // marked expressions, no store code is emitted. |
| 1457 expr->CalculateEmitStore(); | 1467 expr->CalculateEmitStore(); |
| 1458 | 1468 |
| 1469 AccessorTable accessor_table(isolate()->zone()); |
| 1459 for (int i = 0; i < expr->properties()->length(); i++) { | 1470 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1460 ObjectLiteral::Property* property = expr->properties()->at(i); | 1471 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1461 if (property->IsCompileTimeValue()) continue; | 1472 if (property->IsCompileTimeValue()) continue; |
| 1462 | 1473 |
| 1463 Literal* key = property->key(); | 1474 Literal* key = property->key(); |
| 1464 Expression* value = property->value(); | 1475 Expression* value = property->value(); |
| 1465 if (!result_saved) { | 1476 if (!result_saved) { |
| 1466 __ push(v0); // Save result on stack. | 1477 __ push(v0); // Save result on stack. |
| 1467 result_saved = true; | 1478 result_saved = true; |
| 1468 } | 1479 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1498 VisitForStackValue(value); | 1509 VisitForStackValue(value); |
| 1499 if (property->emit_store()) { | 1510 if (property->emit_store()) { |
| 1500 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. | 1511 __ li(a0, Operand(Smi::FromInt(NONE))); // PropertyAttributes. |
| 1501 __ push(a0); | 1512 __ push(a0); |
| 1502 __ CallRuntime(Runtime::kSetProperty, 4); | 1513 __ CallRuntime(Runtime::kSetProperty, 4); |
| 1503 } else { | 1514 } else { |
| 1504 __ Drop(3); | 1515 __ Drop(3); |
| 1505 } | 1516 } |
| 1506 break; | 1517 break; |
| 1507 case ObjectLiteral::Property::GETTER: | 1518 case ObjectLiteral::Property::GETTER: |
| 1519 accessor_table.find(key)->second->getter = value; |
| 1520 break; |
| 1508 case ObjectLiteral::Property::SETTER: | 1521 case ObjectLiteral::Property::SETTER: |
| 1509 // Duplicate receiver on stack. | 1522 accessor_table.find(key)->second->setter = value; |
| 1510 __ lw(a0, MemOperand(sp)); | |
| 1511 __ push(a0); | |
| 1512 VisitForStackValue(key); | |
| 1513 if (property->kind() == ObjectLiteral::Property::GETTER) { | |
| 1514 VisitForStackValue(value); | |
| 1515 __ LoadRoot(a1, Heap::kNullValueRootIndex); | |
| 1516 __ push(a1); | |
| 1517 } else { | |
| 1518 __ LoadRoot(a1, Heap::kNullValueRootIndex); | |
| 1519 __ push(a1); | |
| 1520 VisitForStackValue(value); | |
| 1521 } | |
| 1522 __ li(a0, Operand(Smi::FromInt(NONE))); | |
| 1523 __ push(a0); | |
| 1524 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); | |
| 1525 break; | 1523 break; |
| 1526 } | 1524 } |
| 1527 } | 1525 } |
| 1528 | 1526 |
| 1527 // Emit code to define accessors, using only a single call to the runtime for |
| 1528 // each pair of corresponding getters and setters. |
| 1529 for (AccessorTable::Iterator it = accessor_table.begin(); |
| 1530 it != accessor_table.end(); |
| 1531 ++it) { |
| 1532 __ lw(a0, MemOperand(sp)); // Duplicate receiver. |
| 1533 __ push(a0); |
| 1534 VisitForStackValue(it->first); |
| 1535 EmitAccessor(it->second->getter); |
| 1536 EmitAccessor(it->second->setter); |
| 1537 __ li(a0, Operand(Smi::FromInt(NONE))); |
| 1538 __ push(a0); |
| 1539 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1540 } |
| 1541 |
| 1529 if (expr->has_function()) { | 1542 if (expr->has_function()) { |
| 1530 ASSERT(result_saved); | 1543 ASSERT(result_saved); |
| 1531 __ lw(a0, MemOperand(sp)); | 1544 __ lw(a0, MemOperand(sp)); |
| 1532 __ push(a0); | 1545 __ push(a0); |
| 1533 __ CallRuntime(Runtime::kToFastProperties, 1); | 1546 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1534 } | 1547 } |
| 1535 | 1548 |
| 1536 if (result_saved) { | 1549 if (result_saved) { |
| 1537 context()->PlugTOS(); | 1550 context()->PlugTOS(); |
| 1538 } else { | 1551 } else { |
| (...skipping 2951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4490 *context_length = 0; | 4503 *context_length = 0; |
| 4491 return previous_; | 4504 return previous_; |
| 4492 } | 4505 } |
| 4493 | 4506 |
| 4494 | 4507 |
| 4495 #undef __ | 4508 #undef __ |
| 4496 | 4509 |
| 4497 } } // namespace v8::internal | 4510 } } // namespace v8::internal |
| 4498 | 4511 |
| 4499 #endif // V8_TARGET_ARCH_MIPS | 4512 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |