Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 1841073003: VM: Fix receiver type propagation in presence of try-catch. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments, added test Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_
6 #define VM_INTERMEDIATE_LANGUAGE_H_ 6 #define VM_INTERMEDIATE_LANGUAGE_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/growable_array.h" 10 #include "vm/growable_array.h"
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 1551
1552 private: 1552 private:
1553 const intptr_t indirect_id_; 1553 const intptr_t indirect_id_;
1554 }; 1554 };
1555 1555
1556 1556
1557 class CatchBlockEntryInstr : public BlockEntryInstr { 1557 class CatchBlockEntryInstr : public BlockEntryInstr {
1558 public: 1558 public:
1559 CatchBlockEntryInstr(intptr_t block_id, 1559 CatchBlockEntryInstr(intptr_t block_id,
1560 intptr_t try_index, 1560 intptr_t try_index,
1561 GraphEntryInstr* graph_entry,
1561 const Array& handler_types, 1562 const Array& handler_types,
1562 intptr_t catch_try_index, 1563 intptr_t catch_try_index,
1563 const LocalVariable& exception_var, 1564 const LocalVariable& exception_var,
1564 const LocalVariable& stacktrace_var, 1565 const LocalVariable& stacktrace_var,
1565 bool needs_stacktrace) 1566 bool needs_stacktrace)
1566 : BlockEntryInstr(block_id, try_index), 1567 : BlockEntryInstr(block_id, try_index),
1568 graph_entry_(graph_entry),
1567 predecessor_(NULL), 1569 predecessor_(NULL),
1568 catch_handler_types_(Array::ZoneHandle(handler_types.raw())), 1570 catch_handler_types_(Array::ZoneHandle(handler_types.raw())),
1569 catch_try_index_(catch_try_index), 1571 catch_try_index_(catch_try_index),
1570 exception_var_(exception_var), 1572 exception_var_(exception_var),
1571 stacktrace_var_(stacktrace_var), 1573 stacktrace_var_(stacktrace_var),
1572 needs_stacktrace_(needs_stacktrace) { } 1574 needs_stacktrace_(needs_stacktrace) { }
1573 1575
1574 DECLARE_INSTRUCTION(CatchBlockEntry) 1576 DECLARE_INSTRUCTION(CatchBlockEntry)
1575 1577
1576 virtual intptr_t PredecessorCount() const { 1578 virtual intptr_t PredecessorCount() const {
1577 return (predecessor_ == NULL) ? 0 : 1; 1579 return (predecessor_ == NULL) ? 0 : 1;
1578 } 1580 }
1579 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { 1581 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const {
1580 ASSERT((index == 0) && (predecessor_ != NULL)); 1582 ASSERT((index == 0) && (predecessor_ != NULL));
1581 return predecessor_; 1583 return predecessor_;
1582 } 1584 }
1583 1585
1586 GraphEntryInstr* graph_entry() const { return graph_entry_; }
1587
1584 const LocalVariable& exception_var() const { return exception_var_; } 1588 const LocalVariable& exception_var() const { return exception_var_; }
1585 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } 1589 const LocalVariable& stacktrace_var() const { return stacktrace_var_; }
1586 1590
1587 bool needs_stacktrace() const { return needs_stacktrace_; } 1591 bool needs_stacktrace() const { return needs_stacktrace_; }
1588 1592
1589 // Returns try index for the try block to which this catch handler 1593 // Returns try index for the try block to which this catch handler
1590 // corresponds. 1594 // corresponds.
1591 intptr_t catch_try_index() const { 1595 intptr_t catch_try_index() const {
1592 return catch_try_index_; 1596 return catch_try_index_;
1593 } 1597 }
1594 GrowableArray<Definition*>* initial_definitions() { 1598 GrowableArray<Definition*>* initial_definitions() {
1595 return &initial_definitions_; 1599 return &initial_definitions_;
1596 } 1600 }
1597 1601
1598 PRINT_TO_SUPPORT 1602 PRINT_TO_SUPPORT
1599 1603
1600 private: 1604 private:
1601 friend class BlockEntryInstr; // Access to predecessor_ when inlining. 1605 friend class BlockEntryInstr; // Access to predecessor_ when inlining.
1602 1606
1603 virtual void ClearPredecessors() { predecessor_ = NULL; } 1607 virtual void ClearPredecessors() { predecessor_ = NULL; }
1604 virtual void AddPredecessor(BlockEntryInstr* predecessor) { 1608 virtual void AddPredecessor(BlockEntryInstr* predecessor) {
1605 ASSERT(predecessor_ == NULL); 1609 ASSERT(predecessor_ == NULL);
1606 predecessor_ = predecessor; 1610 predecessor_ = predecessor;
1607 } 1611 }
1608 1612
1613 GraphEntryInstr* graph_entry_;
1609 BlockEntryInstr* predecessor_; 1614 BlockEntryInstr* predecessor_;
1610 const Array& catch_handler_types_; 1615 const Array& catch_handler_types_;
1611 const intptr_t catch_try_index_; 1616 const intptr_t catch_try_index_;
1612 GrowableArray<Definition*> initial_definitions_; 1617 GrowableArray<Definition*> initial_definitions_;
1613 const LocalVariable& exception_var_; 1618 const LocalVariable& exception_var_;
1614 const LocalVariable& stacktrace_var_; 1619 const LocalVariable& stacktrace_var_;
1615 const bool needs_stacktrace_; 1620 const bool needs_stacktrace_;
1616 1621
1617 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr); 1622 DISALLOW_COPY_AND_ASSIGN(CatchBlockEntryInstr);
1618 }; 1623 };
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 1910
1906 1911
1907 class InductionVariableInfo; 1912 class InductionVariableInfo;
1908 1913
1909 1914
1910 class PhiInstr : public Definition { 1915 class PhiInstr : public Definition {
1911 public: 1916 public:
1912 PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) 1917 PhiInstr(JoinEntryInstr* block, intptr_t num_inputs)
1913 : block_(block), 1918 : block_(block),
1914 inputs_(num_inputs), 1919 inputs_(num_inputs),
1915 is_alive_(false),
1916 representation_(kTagged), 1920 representation_(kTagged),
1917 reaching_defs_(NULL), 1921 reaching_defs_(NULL),
1918 loop_variable_info_(NULL) { 1922 loop_variable_info_(NULL),
1923 is_alive_(false),
1924 is_receiver_(kUnknownReceiver) {
1919 for (intptr_t i = 0; i < num_inputs; ++i) { 1925 for (intptr_t i = 0; i < num_inputs; ++i) {
1920 inputs_.Add(NULL); 1926 inputs_.Add(NULL);
1921 } 1927 }
1922 } 1928 }
1923 1929
1924 // Get the block entry for that instruction. 1930 // Get the block entry for that instruction.
1925 virtual BlockEntryInstr* GetBlock() { return block(); } 1931 virtual BlockEntryInstr* GetBlock() { return block(); }
1926 JoinEntryInstr* block() const { return block_; } 1932 JoinEntryInstr* block() const { return block_; }
1927 1933
1928 virtual CompileType ComputeType() const; 1934 virtual CompileType ComputeType() const;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 void set_induction_variable_info(InductionVariableInfo* info) { 1984 void set_induction_variable_info(InductionVariableInfo* info) {
1979 loop_variable_info_ = info; 1985 loop_variable_info_ = info;
1980 } 1986 }
1981 1987
1982 InductionVariableInfo* induction_variable_info() { 1988 InductionVariableInfo* induction_variable_info() {
1983 return loop_variable_info_; 1989 return loop_variable_info_;
1984 } 1990 }
1985 1991
1986 PRINT_TO_SUPPORT 1992 PRINT_TO_SUPPORT
1987 1993
1994 enum ReceiverType {
1995 kUnknownReceiver = -1,
1996 kNotReceiver = 0,
1997 kReceiver = 1
1998 };
1999
2000 ReceiverType is_receiver() const {
2001 return static_cast<ReceiverType>(is_receiver_);
2002 }
2003
2004 void set_is_receiver(ReceiverType is_receiver) {
2005 ASSERT(is_receiver_ == kUnknownReceiver);
2006 is_receiver_ = is_receiver;
2007 }
2008
1988 private: 2009 private:
1989 // Direct access to inputs_ in order to resize it due to unreachable 2010 // Direct access to inputs_ in order to resize it due to unreachable
1990 // predecessors. 2011 // predecessors.
1991 friend class ConstantPropagator; 2012 friend class ConstantPropagator;
1992 2013
1993 void RawSetInputAt(intptr_t i, Value* value) { inputs_[i] = value; } 2014 void RawSetInputAt(intptr_t i, Value* value) { inputs_[i] = value; }
1994 2015
1995 JoinEntryInstr* block_; 2016 JoinEntryInstr* block_;
1996 GrowableArray<Value*> inputs_; 2017 GrowableArray<Value*> inputs_;
1997 bool is_alive_;
1998 Representation representation_; 2018 Representation representation_;
1999
2000 BitVector* reaching_defs_; 2019 BitVector* reaching_defs_;
2001 InductionVariableInfo* loop_variable_info_; 2020 InductionVariableInfo* loop_variable_info_;
2021 bool is_alive_;
2022 int8_t is_receiver_;
2002 2023
2003 DISALLOW_COPY_AND_ASSIGN(PhiInstr); 2024 DISALLOW_COPY_AND_ASSIGN(PhiInstr);
2004 }; 2025 };
2005 2026
2006 2027
2007 class ParameterInstr : public Definition { 2028 class ParameterInstr : public Definition {
2008 public: 2029 public:
2009 ParameterInstr(intptr_t index, 2030 ParameterInstr(intptr_t index,
2010 BlockEntryInstr* block, 2031 BlockEntryInstr* block,
2011 Register base_reg = FPREG) 2032 Register base_reg = FPREG)
(...skipping 6248 matching lines...) Expand 10 before | Expand all | Expand 10 after
8260 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ 8281 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \
8261 UNIMPLEMENTED(); \ 8282 UNIMPLEMENTED(); \
8262 return NULL; \ 8283 return NULL; \
8263 } \ 8284 } \
8264 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8285 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8265 8286
8266 8287
8267 } // namespace dart 8288 } // namespace dart
8268 8289
8269 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8290 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698