| 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 6546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6557 | 6557 |
| 6558 void HGraphBuilder::GenerateValueOf(CallRuntime* call) { | 6558 void HGraphBuilder::GenerateValueOf(CallRuntime* call) { |
| 6559 ASSERT(call->arguments()->length() == 1); | 6559 ASSERT(call->arguments()->length() == 1); |
| 6560 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6560 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6561 HValue* value = Pop(); | 6561 HValue* value = Pop(); |
| 6562 HValueOf* result = new(zone()) HValueOf(value); | 6562 HValueOf* result = new(zone()) HValueOf(value); |
| 6563 return ast_context()->ReturnInstruction(result, call->id()); | 6563 return ast_context()->ReturnInstruction(result, call->id()); |
| 6564 } | 6564 } |
| 6565 | 6565 |
| 6566 | 6566 |
| 6567 void HGraphBuilder::GenerateDateField(CallRuntime* call) { |
| 6568 ASSERT(call->arguments()->length() == 2); |
| 6569 ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral()); |
| 6570 int index = |
| 6571 Smi::cast(*(call->arguments()->at(1)->AsLiteral()->handle()))->value(); |
| 6572 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6573 HValue* value = Pop(); |
| 6574 HDateField* result = new(zone()) HDateField(value, index); |
| 6575 return ast_context()->ReturnInstruction(result, call->id()); |
| 6576 } |
| 6577 |
| 6578 |
| 6567 void HGraphBuilder::GenerateSetValueOf(CallRuntime* call) { | 6579 void HGraphBuilder::GenerateSetValueOf(CallRuntime* call) { |
| 6568 ASSERT(call->arguments()->length() == 2); | 6580 ASSERT(call->arguments()->length() == 2); |
| 6569 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6581 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6570 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 6582 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
| 6571 HValue* value = Pop(); | 6583 HValue* value = Pop(); |
| 6572 HValue* object = Pop(); | 6584 HValue* object = Pop(); |
| 6573 // Check if object is a not a smi. | 6585 // Check if object is a not a smi. |
| 6574 HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(object); | 6586 HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(object); |
| 6575 HBasicBlock* if_smi = graph()->CreateBasicBlock(); | 6587 HBasicBlock* if_smi = graph()->CreateBasicBlock(); |
| 6576 HBasicBlock* if_heap_object = graph()->CreateBasicBlock(); | 6588 HBasicBlock* if_heap_object = graph()->CreateBasicBlock(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6599 value, | 6611 value, |
| 6600 true, // in-object store. | 6612 true, // in-object store. |
| 6601 JSValue::kValueOffset)); | 6613 JSValue::kValueOffset)); |
| 6602 if_js_value->Goto(join); | 6614 if_js_value->Goto(join); |
| 6603 join->SetJoinId(call->id()); | 6615 join->SetJoinId(call->id()); |
| 6604 set_current_block(join); | 6616 set_current_block(join); |
| 6605 return ast_context()->ReturnValue(value); | 6617 return ast_context()->ReturnValue(value); |
| 6606 } | 6618 } |
| 6607 | 6619 |
| 6608 | 6620 |
| 6621 void HGraphBuilder::GenerateSetDateField(CallRuntime* call) { |
| 6622 ASSERT(call->arguments()->length() == 3); |
| 6623 ASSERT_NE(NULL, call->arguments()->at(1)->AsLiteral()); |
| 6624 int index = |
| 6625 Smi::cast(*(call->arguments()->at(1)->AsLiteral()->handle()))->value(); |
| 6626 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6627 CHECK_ALIVE(VisitForValue(call->arguments()->at(2))); |
| 6628 HValue* value = Pop(); |
| 6629 HValue* object = Pop(); |
| 6630 // Check if object is a not a smi. |
| 6631 HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(object); |
| 6632 HBasicBlock* if_smi = graph()->CreateBasicBlock(); |
| 6633 HBasicBlock* if_heap_object = graph()->CreateBasicBlock(); |
| 6634 HBasicBlock* join = graph()->CreateBasicBlock(); |
| 6635 smicheck->SetSuccessorAt(0, if_smi); |
| 6636 smicheck->SetSuccessorAt(1, if_heap_object); |
| 6637 current_block()->Finish(smicheck); |
| 6638 if_smi->Goto(join); |
| 6639 |
| 6640 // Check if object is a JSDate. |
| 6641 set_current_block(if_heap_object); |
| 6642 HHasInstanceTypeAndBranch* typecheck = |
| 6643 new(zone()) HHasInstanceTypeAndBranch(object, JS_DATE_TYPE); |
| 6644 HBasicBlock* if_js_date = graph()->CreateBasicBlock(); |
| 6645 HBasicBlock* not_js_date = graph()->CreateBasicBlock(); |
| 6646 typecheck->SetSuccessorAt(0, if_js_date); |
| 6647 typecheck->SetSuccessorAt(1, not_js_date); |
| 6648 current_block()->Finish(typecheck); |
| 6649 not_js_date->Goto(join); |
| 6650 |
| 6651 // Create in-object property store to right offset. |
| 6652 set_current_block(if_js_date); |
| 6653 Handle<String> name = isolate()->factory()->undefined_symbol(); |
| 6654 AddInstruction( |
| 6655 new HStoreNamedField(object, |
| 6656 name, |
| 6657 value, |
| 6658 true, // in-object store. |
| 6659 JSDate::kYearOffset + kPointerSize * index)); |
| 6660 if_js_date->Goto(join); |
| 6661 join->SetJoinId(call->id()); |
| 6662 set_current_block(join); |
| 6663 return ast_context()->ReturnValue(value); |
| 6664 } |
| 6665 |
| 6666 |
| 6609 // Fast support for charCodeAt(n). | 6667 // Fast support for charCodeAt(n). |
| 6610 void HGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { | 6668 void HGraphBuilder::GenerateStringCharCodeAt(CallRuntime* call) { |
| 6611 ASSERT(call->arguments()->length() == 2); | 6669 ASSERT(call->arguments()->length() == 2); |
| 6612 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6670 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 6613 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 6671 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
| 6614 HValue* index = Pop(); | 6672 HValue* index = Pop(); |
| 6615 HValue* string = Pop(); | 6673 HValue* string = Pop(); |
| 6616 HValue* context = environment()->LookupContext(); | 6674 HValue* context = environment()->LookupContext(); |
| 6617 HStringCharCodeAt* result = BuildStringCharCodeAt(context, string, index); | 6675 HStringCharCodeAt* result = BuildStringCharCodeAt(context, string, index); |
| 6618 return ast_context()->ReturnInstruction(result, call->id()); | 6676 return ast_context()->ReturnInstruction(result, call->id()); |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7450 } | 7508 } |
| 7451 } | 7509 } |
| 7452 | 7510 |
| 7453 #ifdef DEBUG | 7511 #ifdef DEBUG |
| 7454 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7512 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 7455 if (allocator_ != NULL) allocator_->Verify(); | 7513 if (allocator_ != NULL) allocator_->Verify(); |
| 7456 #endif | 7514 #endif |
| 7457 } | 7515 } |
| 7458 | 7516 |
| 7459 } } // namespace v8::internal | 7517 } } // namespace v8::internal |
| OLD | NEW |