| 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 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 __ movq(FieldOperand(rax, i + kPointerSize), rcx); | 1370 __ movq(FieldOperand(rax, i + kPointerSize), rcx); |
| 1371 } | 1371 } |
| 1372 if ((size % (2 * kPointerSize)) != 0) { | 1372 if ((size % (2 * kPointerSize)) != 0) { |
| 1373 __ movq(rdx, FieldOperand(rbx, size - kPointerSize)); | 1373 __ movq(rdx, FieldOperand(rbx, size - kPointerSize)); |
| 1374 __ movq(FieldOperand(rax, size - kPointerSize), rdx); | 1374 __ movq(FieldOperand(rax, size - kPointerSize), rdx); |
| 1375 } | 1375 } |
| 1376 context()->Plug(rax); | 1376 context()->Plug(rax); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 | 1379 |
| 1380 void FullCodeGenerator::EmitAccessor(Expression* expression) { |
| 1381 if (expression == NULL) { |
| 1382 __ PushRoot(Heap::kNullValueRootIndex); |
| 1383 } else { |
| 1384 VisitForStackValue(expression); |
| 1385 } |
| 1386 } |
| 1387 |
| 1388 |
| 1380 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1389 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1381 Comment cmnt(masm_, "[ ObjectLiteral"); | 1390 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1382 Handle<FixedArray> constant_properties = expr->constant_properties(); | 1391 Handle<FixedArray> constant_properties = expr->constant_properties(); |
| 1383 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1392 __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1384 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); | 1393 __ push(FieldOperand(rdi, JSFunction::kLiteralsOffset)); |
| 1385 __ Push(Smi::FromInt(expr->literal_index())); | 1394 __ Push(Smi::FromInt(expr->literal_index())); |
| 1386 __ Push(constant_properties); | 1395 __ Push(constant_properties); |
| 1387 int flags = expr->fast_elements() | 1396 int flags = expr->fast_elements() |
| 1388 ? ObjectLiteral::kFastElements | 1397 ? ObjectLiteral::kFastElements |
| 1389 : ObjectLiteral::kNoFlags; | 1398 : ObjectLiteral::kNoFlags; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1404 | 1413 |
| 1405 // If result_saved is true the result is on top of the stack. If | 1414 // If result_saved is true the result is on top of the stack. If |
| 1406 // result_saved is false the result is in rax. | 1415 // result_saved is false the result is in rax. |
| 1407 bool result_saved = false; | 1416 bool result_saved = false; |
| 1408 | 1417 |
| 1409 // Mark all computed expressions that are bound to a key that | 1418 // Mark all computed expressions that are bound to a key that |
| 1410 // is shadowed by a later occurrence of the same key. For the | 1419 // is shadowed by a later occurrence of the same key. For the |
| 1411 // marked expressions, no store code is emitted. | 1420 // marked expressions, no store code is emitted. |
| 1412 expr->CalculateEmitStore(); | 1421 expr->CalculateEmitStore(); |
| 1413 | 1422 |
| 1423 AccessorTable accessor_table(isolate()->zone()); |
| 1414 for (int i = 0; i < expr->properties()->length(); i++) { | 1424 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1415 ObjectLiteral::Property* property = expr->properties()->at(i); | 1425 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1416 if (property->IsCompileTimeValue()) continue; | 1426 if (property->IsCompileTimeValue()) continue; |
| 1417 | 1427 |
| 1418 Literal* key = property->key(); | 1428 Literal* key = property->key(); |
| 1419 Expression* value = property->value(); | 1429 Expression* value = property->value(); |
| 1420 if (!result_saved) { | 1430 if (!result_saved) { |
| 1421 __ push(rax); // Save result on the stack | 1431 __ push(rax); // Save result on the stack |
| 1422 result_saved = true; | 1432 result_saved = true; |
| 1423 } | 1433 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1448 __ push(Operand(rsp, 0)); // Duplicate receiver. | 1458 __ push(Operand(rsp, 0)); // Duplicate receiver. |
| 1449 VisitForStackValue(key); | 1459 VisitForStackValue(key); |
| 1450 VisitForStackValue(value); | 1460 VisitForStackValue(value); |
| 1451 if (property->emit_store()) { | 1461 if (property->emit_store()) { |
| 1452 __ Push(Smi::FromInt(NONE)); // PropertyAttributes | 1462 __ Push(Smi::FromInt(NONE)); // PropertyAttributes |
| 1453 __ CallRuntime(Runtime::kSetProperty, 4); | 1463 __ CallRuntime(Runtime::kSetProperty, 4); |
| 1454 } else { | 1464 } else { |
| 1455 __ Drop(3); | 1465 __ Drop(3); |
| 1456 } | 1466 } |
| 1457 break; | 1467 break; |
| 1468 case ObjectLiteral::Property::GETTER: |
| 1469 accessor_table.find(key)->second->getter = value; |
| 1470 break; |
| 1458 case ObjectLiteral::Property::SETTER: | 1471 case ObjectLiteral::Property::SETTER: |
| 1459 case ObjectLiteral::Property::GETTER: | 1472 accessor_table.find(key)->second->setter = value; |
| 1460 __ push(Operand(rsp, 0)); // Duplicate receiver. | |
| 1461 VisitForStackValue(key); | |
| 1462 if (property->kind() == ObjectLiteral::Property::GETTER) { | |
| 1463 VisitForStackValue(value); | |
| 1464 __ PushRoot(Heap::kNullValueRootIndex); | |
| 1465 } else { | |
| 1466 __ PushRoot(Heap::kNullValueRootIndex); | |
| 1467 VisitForStackValue(value); | |
| 1468 } | |
| 1469 __ Push(Smi::FromInt(NONE)); | |
| 1470 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); | |
| 1471 break; | 1473 break; |
| 1472 } | 1474 } |
| 1473 } | 1475 } |
| 1474 | 1476 |
| 1477 // Emit code to define accessors, using only a single call to the runtime for |
| 1478 // each pair of corresponding getters and setters. |
| 1479 for (AccessorTable::Iterator it = accessor_table.begin(); |
| 1480 it != accessor_table.end(); |
| 1481 ++it) { |
| 1482 __ push(Operand(rsp, 0)); // Duplicate receiver. |
| 1483 VisitForStackValue(it->first); |
| 1484 EmitAccessor(it->second->getter); |
| 1485 EmitAccessor(it->second->setter); |
| 1486 __ Push(Smi::FromInt(NONE)); |
| 1487 __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1488 } |
| 1489 |
| 1475 if (expr->has_function()) { | 1490 if (expr->has_function()) { |
| 1476 ASSERT(result_saved); | 1491 ASSERT(result_saved); |
| 1477 __ push(Operand(rsp, 0)); | 1492 __ push(Operand(rsp, 0)); |
| 1478 __ CallRuntime(Runtime::kToFastProperties, 1); | 1493 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1479 } | 1494 } |
| 1480 | 1495 |
| 1481 if (result_saved) { | 1496 if (result_saved) { |
| 1482 context()->PlugTOS(); | 1497 context()->PlugTOS(); |
| 1483 } else { | 1498 } else { |
| 1484 context()->Plug(rax); | 1499 context()->Plug(rax); |
| (...skipping 2929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4414 *context_length = 0; | 4429 *context_length = 0; |
| 4415 return previous_; | 4430 return previous_; |
| 4416 } | 4431 } |
| 4417 | 4432 |
| 4418 | 4433 |
| 4419 #undef __ | 4434 #undef __ |
| 4420 | 4435 |
| 4421 } } // namespace v8::internal | 4436 } } // namespace v8::internal |
| 4422 | 4437 |
| 4423 #endif // V8_TARGET_ARCH_X64 | 4438 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |