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

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

Issue 11280230: Optimize checked mode asserts with uninstantiated types and known constant type-arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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"
11 #include "vm/handles_impl.h" 11 #include "vm/handles_impl.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 class BitVector; 17 class BitVector;
18 class BlockEntryInstr; 18 class BlockEntryInstr;
19 class BufferFormatter; 19 class BufferFormatter;
20 class ComparisonInstr; 20 class ComparisonInstr;
21 class ControlInstruction; 21 class ControlInstruction;
22 class Definition; 22 class Definition;
23 class Environment; 23 class Environment;
24 class FlowGraphCompiler; 24 class FlowGraphCompiler;
25 class FlowGraphVisitor; 25 class FlowGraphVisitor;
26 class Instruction; 26 class Instruction;
27 class LocalVariable; 27 class LocalVariable;
28 class Range; 28 class Range;
29 class FlowGraphOptimizer;
29 30
30 31
31 // TODO(srdjan): Add _ByteArrayBase, get:length. 32 // TODO(srdjan): Add _ByteArrayBase, get:length.
32 // TODO(srdjan): Unify with INTRINSIC_LIST. 33 // TODO(srdjan): Unify with INTRINSIC_LIST.
33 // (class-name, function-name, recognized enum, fingerprint). 34 // (class-name, function-name, recognized enum, fingerprint).
34 // See intrinsifier for fingerprint computation. 35 // See intrinsifier for fingerprint computation.
35 #define RECOGNIZED_LIST(V) \ 36 #define RECOGNIZED_LIST(V) \
36 V(_ObjectArray, get:length, ObjectArrayLength, 405297088) \ 37 V(_ObjectArray, get:length, ObjectArrayLength, 405297088) \
37 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \ 38 V(_ImmutableArray, get:length, ImmutableArrayLength, 433698233) \
38 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \ 39 V(_GrowableObjectArray, get:length, GrowableArrayLength, 725548050) \
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 // that input operands conversions inserted for this instruction can jump 463 // that input operands conversions inserted for this instruction can jump
463 // to. 464 // to.
464 virtual intptr_t DeoptimizationTarget() const { 465 virtual intptr_t DeoptimizationTarget() const {
465 UNREACHABLE(); 466 UNREACHABLE();
466 return Isolate::kNoDeoptId; 467 return Isolate::kNoDeoptId;
467 } 468 }
468 469
469 // Returns a replacement for the instruction or NULL if the instruction can 470 // Returns a replacement for the instruction or NULL if the instruction can
470 // be eliminated. By default returns the this instruction which means no 471 // be eliminated. By default returns the this instruction which means no
471 // change. 472 // change.
472 virtual Instruction* Canonicalize(); 473 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer);
473 474
474 // Insert this instruction before 'next'. 475 // Insert this instruction before 'next'.
475 void InsertBefore(Instruction* next); 476 void InsertBefore(Instruction* next);
476 477
477 // Insert this instruction after 'prev'. 478 // Insert this instruction after 'prev'.
478 void InsertAfter(Instruction* prev); 479 void InsertAfter(Instruction* prev);
479 480
480 // Returns true if the instruction is affected by side effects. 481 // Returns true if the instruction is affected by side effects.
481 // Only instructions that are not affected by side effects can participate 482 // Only instructions that are not affected by side effects can participate
482 // in redundancy elimination or loop invariant code motion. 483 // in redundancy elimination or loop invariant code motion.
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 // - unknown sentinel 1130 // - unknown sentinel
1130 Object& constant_value() const { return constant_value_; } 1131 Object& constant_value() const { return constant_value_; }
1131 1132
1132 virtual void InferRange(); 1133 virtual void InferRange();
1133 1134
1134 Range* range() const { return range_; } 1135 Range* range() const { return range_; }
1135 1136
1136 // Definitions can be canonicalized only into definitions to ensure 1137 // Definitions can be canonicalized only into definitions to ensure
1137 // this check statically we override base Canonicalize with a Canonicalize 1138 // this check statically we override base Canonicalize with a Canonicalize
1138 // returning Definition (return type is covariant). 1139 // returning Definition (return type is covariant).
1139 virtual Definition* Canonicalize(); 1140 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
1140 1141
1141 protected: 1142 protected:
1142 friend class RangeAnalysis; 1143 friend class RangeAnalysis;
1143 1144
1144 Range* range_; 1145 Range* range_;
1145 1146
1146 private: 1147 private:
1147 intptr_t temp_index_; 1148 intptr_t temp_index_;
1148 intptr_t ssa_temp_index_; 1149 intptr_t ssa_temp_index_;
1149 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; 1150 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_;
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 1843
1843 class AssertAssignableInstr : public TemplateDefinition<3> { 1844 class AssertAssignableInstr : public TemplateDefinition<3> {
1844 public: 1845 public:
1845 AssertAssignableInstr(intptr_t token_pos, 1846 AssertAssignableInstr(intptr_t token_pos,
1846 Value* value, 1847 Value* value,
1847 Value* instantiator, 1848 Value* instantiator,
1848 Value* instantiator_type_arguments, 1849 Value* instantiator_type_arguments,
1849 const AbstractType& dst_type, 1850 const AbstractType& dst_type,
1850 const String& dst_name) 1851 const String& dst_name)
1851 : token_pos_(token_pos), 1852 : token_pos_(token_pos),
1852 dst_type_(dst_type), 1853 dst_type_(AbstractType::ZoneHandle(dst_type.raw())),
1853 dst_name_(dst_name), 1854 dst_name_(dst_name),
1854 is_eliminated_(false) { 1855 is_eliminated_(false) {
1855 ASSERT(value != NULL); 1856 ASSERT(value != NULL);
1856 ASSERT(instantiator != NULL); 1857 ASSERT(instantiator != NULL);
1857 ASSERT(instantiator_type_arguments != NULL); 1858 ASSERT(instantiator_type_arguments != NULL);
1858 ASSERT(!dst_type.IsNull()); 1859 ASSERT(!dst_type.IsNull());
1859 ASSERT(!dst_name.IsNull()); 1860 ASSERT(!dst_name.IsNull());
1860 inputs_[0] = value; 1861 inputs_[0] = value;
1861 inputs_[1] = instantiator; 1862 inputs_[1] = instantiator;
1862 inputs_[2] = instantiator_type_arguments; 1863 inputs_[2] = instantiator_type_arguments;
1863 } 1864 }
1864 1865
1865 DECLARE_INSTRUCTION(AssertAssignable) 1866 DECLARE_INSTRUCTION(AssertAssignable)
1866 virtual RawAbstractType* CompileType() const; 1867 virtual RawAbstractType* CompileType() const;
1867 1868
1868 Value* value() const { return inputs_[0]; } 1869 Value* value() const { return inputs_[0]; }
1869 Value* instantiator() const { return inputs_[1]; } 1870 Value* instantiator() const { return inputs_[1]; }
1870 Value* instantiator_type_arguments() const { return inputs_[2]; } 1871 Value* instantiator_type_arguments() const { return inputs_[2]; }
1871 1872
1872 intptr_t token_pos() const { return token_pos_; } 1873 intptr_t token_pos() const { return token_pos_; }
1873 const AbstractType& dst_type() const { return dst_type_; } 1874 const AbstractType& dst_type() const { return dst_type_; }
1875 void set_dst_type(const AbstractType& dst_type) {
1876 dst_type_ = dst_type.raw();
1877 }
1874 const String& dst_name() const { return dst_name_; } 1878 const String& dst_name() const { return dst_name_; }
1875 1879
1876 bool is_eliminated() const { 1880 bool is_eliminated() const {
1877 return is_eliminated_; 1881 return is_eliminated_;
1878 } 1882 }
1879 void eliminate() { 1883 void eliminate() {
1880 ASSERT(!is_eliminated_); 1884 ASSERT(!is_eliminated_);
1881 is_eliminated_ = true; 1885 is_eliminated_ = true;
1882 } 1886 }
1883 1887
1884 virtual void PrintOperandsTo(BufferFormatter* f) const; 1888 virtual void PrintOperandsTo(BufferFormatter* f) const;
1885 1889
1886 virtual bool CanDeoptimize() const { return false; } 1890 virtual bool CanDeoptimize() const { return false; }
1887 1891
1888 virtual bool HasSideEffect() const { return false; } 1892 virtual bool HasSideEffect() const { return false; }
1889 1893
1890 virtual bool AffectedBySideEffect() const { return false; } 1894 virtual bool AffectedBySideEffect() const { return false; }
1891 virtual bool AttributesEqual(Instruction* other) const; 1895 virtual bool AttributesEqual(Instruction* other) const;
1892 1896
1893 virtual intptr_t ResultCid() const { return value()->ResultCid(); } 1897 virtual intptr_t ResultCid() const { return value()->ResultCid(); }
1894 virtual intptr_t GetPropagatedCid(); 1898 virtual intptr_t GetPropagatedCid();
1895 1899
1896 virtual Definition* Canonicalize(); 1900 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
1897 1901
1898 private: 1902 private:
1899 const intptr_t token_pos_; 1903 const intptr_t token_pos_;
1900 const AbstractType& dst_type_; 1904 AbstractType& dst_type_;
1901 const String& dst_name_; 1905 const String& dst_name_;
1902 bool is_eliminated_; 1906 bool is_eliminated_;
1903 1907
1904 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr); 1908 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr);
1905 }; 1909 };
1906 1910
1907 1911
1908 class AssertBooleanInstr : public TemplateDefinition<1> { 1912 class AssertBooleanInstr : public TemplateDefinition<1> {
1909 public: 1913 public:
1910 AssertBooleanInstr(intptr_t token_pos, Value* value) 1914 AssertBooleanInstr(intptr_t token_pos, Value* value)
(...skipping 21 matching lines...) Expand all
1932 1936
1933 virtual bool CanDeoptimize() const { return false; } 1937 virtual bool CanDeoptimize() const { return false; }
1934 1938
1935 virtual bool HasSideEffect() const { return false; } 1939 virtual bool HasSideEffect() const { return false; }
1936 1940
1937 virtual bool AffectedBySideEffect() const { return false; } 1941 virtual bool AffectedBySideEffect() const { return false; }
1938 virtual bool AttributesEqual(Instruction* other) const { return true; } 1942 virtual bool AttributesEqual(Instruction* other) const { return true; }
1939 1943
1940 virtual intptr_t ResultCid() const { return kBoolCid; } 1944 virtual intptr_t ResultCid() const { return kBoolCid; }
1941 1945
1942 virtual Definition* Canonicalize(); 1946 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
1943 1947
1944 private: 1948 private:
1945 const intptr_t token_pos_; 1949 const intptr_t token_pos_;
1946 bool is_eliminated_; 1950 bool is_eliminated_;
1947 1951
1948 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr); 1952 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr);
1949 }; 1953 };
1950 1954
1951 1955
1952 class ArgumentDefinitionTestInstr : public TemplateDefinition<1> { 1956 class ArgumentDefinitionTestInstr : public TemplateDefinition<1> {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 2245
2242 virtual void PrintOperandsTo(BufferFormatter* f) const; 2246 virtual void PrintOperandsTo(BufferFormatter* f) const;
2243 2247
2244 virtual bool CanDeoptimize() const { return false; } 2248 virtual bool CanDeoptimize() const { return false; }
2245 2249
2246 virtual bool HasSideEffect() const { return false; } 2250 virtual bool HasSideEffect() const { return false; }
2247 2251
2248 virtual bool AttributesEqual(Instruction* other) const; 2252 virtual bool AttributesEqual(Instruction* other) const;
2249 virtual bool AffectedBySideEffect() const { return false; } 2253 virtual bool AffectedBySideEffect() const { return false; }
2250 2254
2251 virtual Definition* Canonicalize(); 2255 virtual Definition* Canonicalize(FlowGraphOptimizer* optimizer);
2252 2256
2253 virtual intptr_t ResultCid() const { return kBoolCid; } 2257 virtual intptr_t ResultCid() const { return kBoolCid; }
2254 2258
2255 virtual void EmitBranchCode(FlowGraphCompiler* compiler, 2259 virtual void EmitBranchCode(FlowGraphCompiler* compiler,
2256 BranchInstr* branch); 2260 BranchInstr* branch);
2257 2261
2258 bool needs_number_check() const { return needs_number_check_; } 2262 bool needs_number_check() const { return needs_number_check_; }
2259 void set_needs_number_check(bool value) { needs_number_check_ = value; } 2263 void set_needs_number_check(bool value) { needs_number_check_ = value; }
2260 2264
2261 private: 2265 private:
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3385 virtual bool HasSideEffect() const { return false; } 3389 virtual bool HasSideEffect() const { return false; }
3386 3390
3387 virtual bool AttributesEqual(Instruction* other) const { return true; } 3391 virtual bool AttributesEqual(Instruction* other) const { return true; }
3388 3392
3389 virtual bool AffectedBySideEffect() const { return false; } 3393 virtual bool AffectedBySideEffect() const { return false; }
3390 3394
3391 Value* left() const { return inputs_[0]; } 3395 Value* left() const { return inputs_[0]; }
3392 3396
3393 Value* right() const { return inputs_[1]; } 3397 Value* right() const { return inputs_[1]; }
3394 3398
3395 virtual Instruction* Canonicalize(); 3399 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer);
3396 3400
3397 private: 3401 private:
3398 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr); 3402 DISALLOW_COPY_AND_ASSIGN(CheckEitherNonSmiInstr);
3399 }; 3403 };
3400 3404
3401 3405
3402 class BoxDoubleInstr : public TemplateDefinition<1> { 3406 class BoxDoubleInstr : public TemplateDefinition<1> {
3403 public: 3407 public:
3404 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call) 3408 BoxDoubleInstr(Value* value, InstanceCallInstr* instance_call)
3405 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) { 3409 : token_pos_((instance_call != NULL) ? instance_call->token_pos() : 0) {
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 virtual bool HasSideEffect() const { return false; } 4001 virtual bool HasSideEffect() const { return false; }
3998 4002
3999 virtual bool AttributesEqual(Instruction* other) const; 4003 virtual bool AttributesEqual(Instruction* other) const;
4000 4004
4001 virtual bool AffectedBySideEffect() const { return false; } 4005 virtual bool AffectedBySideEffect() const { return false; }
4002 4006
4003 Value* value() const { return inputs_[0]; } 4007 Value* value() const { return inputs_[0]; }
4004 4008
4005 const ICData& unary_checks() const { return unary_checks_; } 4009 const ICData& unary_checks() const { return unary_checks_; }
4006 4010
4007 virtual Instruction* Canonicalize(); 4011 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer);
4008 4012
4009 virtual void PrintOperandsTo(BufferFormatter* f) const; 4013 virtual void PrintOperandsTo(BufferFormatter* f) const;
4010 4014
4011 private: 4015 private:
4012 const ICData& unary_checks_; 4016 const ICData& unary_checks_;
4013 4017
4014 DISALLOW_COPY_AND_ASSIGN(CheckClassInstr); 4018 DISALLOW_COPY_AND_ASSIGN(CheckClassInstr);
4015 }; 4019 };
4016 4020
4017 4021
(...skipping 12 matching lines...) Expand all
4030 virtual intptr_t ArgumentCount() const { return 0; } 4034 virtual intptr_t ArgumentCount() const { return 0; }
4031 4035
4032 virtual bool CanDeoptimize() const { return true; } 4036 virtual bool CanDeoptimize() const { return true; }
4033 4037
4034 virtual bool HasSideEffect() const { return false; } 4038 virtual bool HasSideEffect() const { return false; }
4035 4039
4036 virtual bool AttributesEqual(Instruction* other) const { return true; } 4040 virtual bool AttributesEqual(Instruction* other) const { return true; }
4037 4041
4038 virtual bool AffectedBySideEffect() const { return false; } 4042 virtual bool AffectedBySideEffect() const { return false; }
4039 4043
4040 virtual Instruction* Canonicalize(); 4044 virtual Instruction* Canonicalize(FlowGraphOptimizer* optimizer);
4041 4045
4042 Value* value() const { return inputs_[0]; } 4046 Value* value() const { return inputs_[0]; }
4043 4047
4044 private: 4048 private:
4045 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr); 4049 DISALLOW_COPY_AND_ASSIGN(CheckSmiInstr);
4046 }; 4050 };
4047 4051
4048 4052
4049 class CheckArrayBoundInstr : public TemplateInstruction<2> { 4053 class CheckArrayBoundInstr : public TemplateInstruction<2> {
4050 public: 4054 public:
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4297 ForwardInstructionIterator* current_iterator_; 4301 ForwardInstructionIterator* current_iterator_;
4298 4302
4299 private: 4303 private:
4300 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4304 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4301 }; 4305 };
4302 4306
4303 4307
4304 } // namespace dart 4308 } // namespace dart
4305 4309
4306 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4310 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698