OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4806 __ Push(Smi::FromInt(node_->literal_index())); | 4806 __ Push(Smi::FromInt(node_->literal_index())); |
4807 // RegExp pattern (2). | 4807 // RegExp pattern (2). |
4808 __ Push(node_->pattern()); | 4808 __ Push(node_->pattern()); |
4809 // RegExp flags (3). | 4809 // RegExp flags (3). |
4810 __ Push(node_->flags()); | 4810 __ Push(node_->flags()); |
4811 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); | 4811 __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); |
4812 if (!boilerplate_.is(rax)) __ movq(boilerplate_, rax); | 4812 if (!boilerplate_.is(rax)) __ movq(boilerplate_, rax); |
4813 } | 4813 } |
4814 | 4814 |
4815 | 4815 |
| 4816 class DeferredAllocateInNewSpace: public DeferredCode { |
| 4817 public: |
| 4818 DeferredAllocateInNewSpace(int size, Register target) |
| 4819 : size_(size), target_(target) { |
| 4820 ASSERT(size >= kPointerSize && size <= Heap::MaxObjectSizeInNewSpace()); |
| 4821 set_comment("[ DeferredAllocateInNewSpace"); |
| 4822 } |
| 4823 void Generate(); |
| 4824 |
| 4825 private: |
| 4826 int size_; |
| 4827 Register target_; |
| 4828 }; |
| 4829 |
| 4830 |
| 4831 void DeferredAllocateInNewSpace::Generate() { |
| 4832 __ Push(Smi::FromInt(size_)); |
| 4833 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
| 4834 if (!target_.is(rax)) { |
| 4835 __ movq(target_, rax); |
| 4836 } |
| 4837 } |
| 4838 |
| 4839 |
4816 void CodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) { | 4840 void CodeGenerator::VisitRegExpLiteral(RegExpLiteral* node) { |
4817 Comment cmnt(masm_, "[ RegExp Literal"); | 4841 Comment cmnt(masm_, "[ RegExp Literal"); |
4818 | 4842 |
4819 // Retrieve the literals array and check the allocated entry. Begin | 4843 // Retrieve the literals array and check the allocated entry. Begin |
4820 // with a writable copy of the function of this activation in a | 4844 // with a writable copy of the function of this activation in a |
4821 // register. | 4845 // register. |
4822 frame_->PushFunction(); | 4846 frame_->PushFunction(); |
4823 Result literals = frame_->Pop(); | 4847 Result literals = frame_->Pop(); |
4824 literals.ToRegister(); | 4848 literals.ToRegister(); |
4825 frame_->Spill(literals.reg()); | 4849 frame_->Spill(literals.reg()); |
4826 | 4850 |
4827 // Load the literals array of the function. | 4851 // Load the literals array of the function. |
4828 __ movq(literals.reg(), | 4852 __ movq(literals.reg(), |
4829 FieldOperand(literals.reg(), JSFunction::kLiteralsOffset)); | 4853 FieldOperand(literals.reg(), JSFunction::kLiteralsOffset)); |
4830 | 4854 |
4831 // Load the literal at the ast saved index. | 4855 // Load the literal at the ast saved index. |
4832 Result boilerplate = allocator_->Allocate(); | 4856 Result boilerplate = allocator_->Allocate(); |
4833 ASSERT(boilerplate.is_valid()); | 4857 ASSERT(boilerplate.is_valid()); |
4834 int literal_offset = | 4858 int literal_offset = |
4835 FixedArray::kHeaderSize + node->literal_index() * kPointerSize; | 4859 FixedArray::kHeaderSize + node->literal_index() * kPointerSize; |
4836 __ movq(boilerplate.reg(), FieldOperand(literals.reg(), literal_offset)); | 4860 __ movq(boilerplate.reg(), FieldOperand(literals.reg(), literal_offset)); |
4837 | 4861 |
4838 // Check whether we need to materialize the RegExp object. If so, | 4862 // Check whether we need to materialize the RegExp object. If so, |
4839 // jump to the deferred code passing the literals array. | 4863 // jump to the deferred code passing the literals array. |
4840 DeferredRegExpLiteral* deferred = | 4864 DeferredRegExpLiteral* deferred = |
4841 new DeferredRegExpLiteral(boilerplate.reg(), literals.reg(), node); | 4865 new DeferredRegExpLiteral(boilerplate.reg(), literals.reg(), node); |
4842 __ CompareRoot(boilerplate.reg(), Heap::kUndefinedValueRootIndex); | 4866 __ CompareRoot(boilerplate.reg(), Heap::kUndefinedValueRootIndex); |
4843 deferred->Branch(equal); | 4867 deferred->Branch(equal); |
4844 deferred->BindExit(); | 4868 deferred->BindExit(); |
4845 literals.Unuse(); | |
4846 | 4869 |
4847 // Push the boilerplate object. | 4870 // Register of boilerplate contains RegExp object. |
| 4871 |
| 4872 Result tmp = allocator()->Allocate(); |
| 4873 ASSERT(tmp.is_valid()); |
| 4874 |
| 4875 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; |
| 4876 |
| 4877 DeferredAllocateInNewSpace* allocate_fallback = |
| 4878 new DeferredAllocateInNewSpace(size, literals.reg()); |
4848 frame_->Push(&boilerplate); | 4879 frame_->Push(&boilerplate); |
| 4880 frame_->SpillTop(); |
| 4881 __ AllocateInNewSpace(size, |
| 4882 literals.reg(), |
| 4883 tmp.reg(), |
| 4884 no_reg, |
| 4885 allocate_fallback->entry_label(), |
| 4886 TAG_OBJECT); |
| 4887 allocate_fallback->BindExit(); |
| 4888 boilerplate = frame_->Pop(); |
| 4889 // Copy from boilerplate to clone and return clone. |
| 4890 |
| 4891 for (int i = 0; i < size; i += kPointerSize) { |
| 4892 __ movq(tmp.reg(), FieldOperand(boilerplate.reg(), i)); |
| 4893 __ movq(FieldOperand(literals.reg(), i), tmp.reg()); |
| 4894 } |
| 4895 frame_->Push(&literals); |
4849 } | 4896 } |
4850 | 4897 |
4851 | 4898 |
4852 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { | 4899 void CodeGenerator::VisitObjectLiteral(ObjectLiteral* node) { |
4853 Comment cmnt(masm_, "[ ObjectLiteral"); | 4900 Comment cmnt(masm_, "[ ObjectLiteral"); |
4854 | 4901 |
4855 // Load a writable copy of the function of this activation in a | 4902 // Load a writable copy of the function of this activation in a |
4856 // register. | 4903 // register. |
4857 frame_->PushFunction(); | 4904 frame_->PushFunction(); |
4858 Result literals = frame_->Pop(); | 4905 Result literals = frame_->Pop(); |
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7007 RegisterFile empty_regs; | 7054 RegisterFile empty_regs; |
7008 SetFrame(clone, &empty_regs); | 7055 SetFrame(clone, &empty_regs); |
7009 __ bind(&runtime); | 7056 __ bind(&runtime); |
7010 result = frame()->CallRuntime(Runtime::kMath_sqrt, 1); | 7057 result = frame()->CallRuntime(Runtime::kMath_sqrt, 1); |
7011 | 7058 |
7012 end.Bind(&result); | 7059 end.Bind(&result); |
7013 frame()->Push(&result); | 7060 frame()->Push(&result); |
7014 } | 7061 } |
7015 | 7062 |
7016 | 7063 |
| 7064 void CodeGenerator::GenerateIsRegExpEquivalent(ZoneList<Expression*>* args) { |
| 7065 ASSERT_EQ(2, args->length()); |
| 7066 Load(args->at(0)); |
| 7067 Load(args->at(1)); |
| 7068 Result right_res = frame_->Pop(); |
| 7069 Result left_res = frame_->Pop(); |
| 7070 right_res.ToRegister(); |
| 7071 left_res.ToRegister(); |
| 7072 Result tmp_res = allocator()->Allocate(); |
| 7073 ASSERT(tmp_res.is_valid()); |
| 7074 Register right = right_res.reg(); |
| 7075 Register left = left_res.reg(); |
| 7076 Register tmp = tmp_res.reg(); |
| 7077 right_res.Unuse(); |
| 7078 left_res.Unuse(); |
| 7079 tmp_res.Unuse(); |
| 7080 __ cmpq(left, right); |
| 7081 destination()->true_target()->Branch(equal); |
| 7082 // Fail if either is a non-HeapObject. |
| 7083 Condition either_smi = |
| 7084 masm()->CheckEitherSmi(left, right, tmp); |
| 7085 destination()->false_target()->Branch(either_smi); |
| 7086 __ movq(tmp, FieldOperand(left, HeapObject::kMapOffset)); |
| 7087 __ cmpb(FieldOperand(tmp, Map::kInstanceTypeOffset), |
| 7088 Immediate(JS_REGEXP_TYPE)); |
| 7089 destination()->false_target()->Branch(not_equal); |
| 7090 __ cmpq(tmp, FieldOperand(right, HeapObject::kMapOffset)); |
| 7091 destination()->false_target()->Branch(not_equal); |
| 7092 __ movq(tmp, FieldOperand(left, JSRegExp::kDataOffset)); |
| 7093 __ cmpq(tmp, FieldOperand(right, JSRegExp::kDataOffset)); |
| 7094 destination()->Split(equal); |
| 7095 } |
| 7096 |
| 7097 |
7017 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { | 7098 void CodeGenerator::VisitCallRuntime(CallRuntime* node) { |
7018 if (CheckForInlineRuntimeCall(node)) { | 7099 if (CheckForInlineRuntimeCall(node)) { |
7019 return; | 7100 return; |
7020 } | 7101 } |
7021 | 7102 |
7022 ZoneList<Expression*>* args = node->arguments(); | 7103 ZoneList<Expression*>* args = node->arguments(); |
7023 Comment cmnt(masm_, "[ CallRuntime"); | 7104 Comment cmnt(masm_, "[ CallRuntime"); |
7024 Runtime::Function* function = node->function(); | 7105 Runtime::Function* function = node->function(); |
7025 | 7106 |
7026 if (function == NULL) { | 7107 if (function == NULL) { |
(...skipping 5508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12535 #undef __ | 12616 #undef __ |
12536 | 12617 |
12537 void RecordWriteStub::Generate(MacroAssembler* masm) { | 12618 void RecordWriteStub::Generate(MacroAssembler* masm) { |
12538 masm->RecordWriteHelper(object_, addr_, scratch_); | 12619 masm->RecordWriteHelper(object_, addr_, scratch_); |
12539 masm->ret(0); | 12620 masm->ret(0); |
12540 } | 12621 } |
12541 | 12622 |
12542 } } // namespace v8::internal | 12623 } } // namespace v8::internal |
12543 | 12624 |
12544 #endif // V8_TARGET_ARCH_X64 | 12625 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |