Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

hir/lir: delete/clone

  • Loading branch information...
commit 6082cbac6f9b77a70767c8607c0970bec3452bf5 1 parent d31db87
@indutny authored
View
2  TODO
@@ -1,7 +1,5 @@
HIR/LIR todos:
* Break/continue
-* Clone
-* Delete
* Vararg arguments (call)
* Speeding up HIR construction
* Cleanup masm
View
2  src/hir-instructions.cc
@@ -11,11 +11,13 @@ namespace internal {
V(Call)\
V(StoreProperty)\
V(LoadProperty)\
+ V(DeleteProperty)\
V(BinOp)\
V(Typeof)\
V(Sizeof)\
V(Keysof)\
V(Not)\
+ V(CloneObject)\
V(AllocateFunction)\
V(AllocateObject)
View
26 src/hir-instructions.h
@@ -45,11 +45,13 @@ class HIRInstruction : public ZoneObject {
kCall,
kStoreProperty,
kLoadProperty,
+ kDeleteProperty,
kBinOp,
kTypeof,
kSizeof,
kKeysof,
kNot,
+ kCloneObject,
kCollectGarbage,
kGetStackTrace,
kAllocateFunction,
@@ -398,6 +400,24 @@ class HIRStoreProperty : public HIRInstruction {
HIRValue* rhs_;
};
+class HIRDeleteProperty : public HIRStubCall {
+ public:
+ HIRDeleteProperty(HIRValue* receiver, HIRValue* property)
+ : HIRStubCall(kDeleteProperty),
+ receiver_(receiver),
+ property_(property) {
+ SetInput(receiver);
+ SetInput(property);
+ }
+
+ inline HIRValue* receiver() { return receiver_; }
+ inline HIRValue* property() { return property_; }
+
+ private:
+ HIRValue* receiver_;
+ HIRValue* property_;
+};
+
class HIRBranchBool : public HIRBranchBase {
public:
HIRBranchBool(HIRValue* clause, HIRBasicBlock* left, HIRBasicBlock* right)
@@ -445,6 +465,12 @@ class HIRNot : public HIRPrefixKeyword {
}
};
+class HIRCloneObject : public HIRPrefixKeyword {
+ public:
+ HIRCloneObject(HIRValue* obj) : HIRPrefixKeyword(kCloneObject, obj) {
+ }
+};
+
class HIRCollectGarbage : public HIRStubCall {
public:
HIRCollectGarbage() : HIRStubCall(kCollectGarbage) {
View
10 src/hir.cc
@@ -993,11 +993,21 @@ AstNode* HIR::VisitReturn(AstNode* node) {
AstNode* HIR::VisitClone(AstNode* node) {
+ AddInstruction(new HIRCloneObject(GetValue(node->lhs())));
+
return node;
}
AstNode* HIR::VisitDelete(AstNode* node) {
+ // TODO: Set error
+ assert(node->lhs()->is(AstNode::kMember));
+
+ HIRValue* property = GetValue(node->lhs()->rhs());
+ HIRValue* receiver = GetValue(node->lhs()->lhs());
+
+ AddInstruction(new HIRDeleteProperty(receiver, property));
+
return node;
}
View
19 src/x64/lir-instructions-x64.cc
@@ -251,6 +251,18 @@ void LIRLoadProperty::Generate() {
}
+LIRDeleteProperty::LIRDeleteProperty() {
+ inputs[0] = ToLIROperand(rax);
+ inputs[1] = ToLIROperand(rbx);
+}
+
+
+void LIRDeleteProperty::Generate() {
+ __ Call(masm()->stubs()->GetDeletePropertyStub());
+ __ Mov(result, Immediate(Heap::kTagNil));
+}
+
+
LIRBranchBool::LIRBranchBool() {
inputs[0] = ToLIROperand(rax);
}
@@ -496,6 +508,13 @@ void LIRNot::Generate() {
}
+void LIRCloneObject::Generate() {
+ __ Mov(rax, inputs[0]);
+ __ Call(masm()->stubs()->GetCloneObjectStub());
+ __ Mov(result, rax);
+}
+
+
void LIRCollectGarbage::Generate() {
__ Call(masm()->stubs()->GetCollectGarbageStub());
__ Mov(result, Immediate(Heap::kTagNil));
View
18 src/x64/lir-instructions-x64.h
@@ -25,6 +25,7 @@ class Operand;
V(LoadRoot)\
V(LoadContext)\
V(LoadProperty)\
+ V(DeleteProperty)\
V(BranchBool)\
V(BinOp)\
V(Call)\
@@ -32,6 +33,7 @@ class Operand;
V(Sizeof)\
V(Keysof)\
V(Not)\
+ V(CloneObject)\
V(CollectGarbage)\
V(GetStackTrace)\
V(AllocateObject)\
@@ -216,6 +218,15 @@ class LIRLoadProperty : public LIRInstructionTemplate<2, 1, 1> {
LIR_COMMON_METHODS(LoadProperty)
};
+class LIRDeleteProperty : public LIRInstructionTemplate<2, 1, 0> {
+ public:
+ LIRDeleteProperty();
+
+ void Generate();
+
+ LIR_COMMON_METHODS(DeleteProperty)
+};
+
class LIRBranchBool : public LIRControlInstructionTemplate<1, 0> {
public:
LIRBranchBool();
@@ -277,6 +288,13 @@ class LIRNot : public LIRInstructionTemplate<1, 1, 0> {
LIR_COMMON_METHODS(Not)
};
+class LIRCloneObject : public LIRInstructionTemplate<1, 1, 0> {
+ public:
+ void Generate();
+
+ LIR_COMMON_METHODS(CloneObject)
+};
+
class LIRCollectGarbage : public LIRInstructionTemplate<0, 1, 0> {
public:
void Generate();
Please sign in to comment.
Something went wrong with that request. Please try again.