Index: runtime/vm/ast.h |
diff --git a/runtime/vm/ast.h b/runtime/vm/ast.h |
index c770d0e7b26b32aa83349a566e8ec9fbed0bf0a0..4ca237268e5a1280eeeda36c8851a30323da699e 100644 |
--- a/runtime/vm/ast.h |
+++ b/runtime/vm/ast.h |
@@ -150,6 +150,10 @@ class AstNode : public ZoneAllocated { |
// the former). |
virtual const Instance* EvalConstExpr() const { return NULL; } |
+ // Return ZoneHandle of a cloned 'value' when in background compilation or |
+ // when testing. Otherwise return 'value' itself. |
+ static const Field* MayCloneField(const Field& value); |
+ |
protected: |
friend class ParsedFunction; |
@@ -1241,7 +1245,8 @@ class LoadInstanceFieldNode : public AstNode { |
LoadInstanceFieldNode(TokenPosition token_pos, |
AstNode* instance, |
const Field& field) |
- : AstNode(token_pos), instance_(instance), field_(field) { |
+ : AstNode(token_pos), instance_(instance), |
+ field_(*MayCloneField(field)) { |
ASSERT(instance_ != NULL); |
ASSERT(field_.IsZoneHandle()); |
} |
@@ -1271,7 +1276,7 @@ class StoreInstanceFieldNode : public AstNode { |
AstNode* value) |
: AstNode(token_pos), |
instance_(instance), |
- field_(field), |
+ field_(*MayCloneField(field)), |
value_(value) { |
ASSERT(instance_ != NULL); |
ASSERT(field_.IsZoneHandle()); |
@@ -1301,7 +1306,9 @@ class StoreInstanceFieldNode : public AstNode { |
class LoadStaticFieldNode : public AstNode { |
public: |
LoadStaticFieldNode(TokenPosition token_pos, const Field& field) |
- : AstNode(token_pos), field_(field), is_deferred_reference_(false) { |
+ : AstNode(token_pos), |
+ field_(*MayCloneField(field)), |
+ is_deferred_reference_(false) { |
ASSERT(field_.IsZoneHandle()); |
} |
@@ -1339,7 +1346,9 @@ class StoreStaticFieldNode : public AstNode { |
StoreStaticFieldNode(TokenPosition token_pos, |
const Field& field, |
AstNode* value) |
- : AstNode(token_pos), field_(field), value_(value) { |
+ : AstNode(token_pos), |
+ field_(*MayCloneField(field)), |
+ value_(value) { |
ASSERT(field_.IsZoneHandle()); |
ASSERT(value_ != NULL); |
} |
@@ -1561,7 +1570,8 @@ class InstanceSetterNode : public AstNode { |
class InitStaticFieldNode : public AstNode { |
public: |
InitStaticFieldNode(TokenPosition token_pos, const Field& field) |
- : AstNode(token_pos), field_(field) { |
+ : AstNode(token_pos), |
+ field_(*MayCloneField(field)) { |
ASSERT(field_.IsZoneHandle()); |
} |