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

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

Issue 10908214: Revert "Whenever possible use length passed to the List constructor for bounds checks instead of lo… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.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"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 M(SmiToDouble) \ 236 M(SmiToDouble) \
237 M(CheckClass) \ 237 M(CheckClass) \
238 M(CheckSmi) \ 238 M(CheckSmi) \
239 M(Constant) \ 239 M(Constant) \
240 M(CheckEitherNonSmi) \ 240 M(CheckEitherNonSmi) \
241 M(UnboxedDoubleBinaryOp) \ 241 M(UnboxedDoubleBinaryOp) \
242 M(MathSqrt) \ 242 M(MathSqrt) \
243 M(UnboxDouble) \ 243 M(UnboxDouble) \
244 M(BoxDouble) \ 244 M(BoxDouble) \
245 M(CheckArrayBound) \ 245 M(CheckArrayBound) \
246 M(CheckBound) \ 246
247 247
248 #define FORWARD_DECLARATION(type) class type##Instr; 248 #define FORWARD_DECLARATION(type) class type##Instr;
249 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) 249 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION)
250 #undef FORWARD_DECLARATION 250 #undef FORWARD_DECLARATION
251 251
252 252
253 // Functions required in all concrete instruction classes. 253 // Functions required in all concrete instruction classes.
254 #define DECLARE_INSTRUCTION(type) \ 254 #define DECLARE_INSTRUCTION(type) \
255 virtual Tag tag() const { return k##type; } \ 255 virtual Tag tag() const { return k##type; } \
256 virtual void Accept(FlowGraphVisitor* visitor); \ 256 virtual void Accept(FlowGraphVisitor* visitor); \
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 private: 438 private:
439 friend class Definition; // Needed for InsertBefore, InsertAfter. 439 friend class Definition; // Needed for InsertBefore, InsertAfter.
440 440
441 // Classes that set deopt_id_. 441 // Classes that set deopt_id_.
442 friend class UnboxDoubleInstr; 442 friend class UnboxDoubleInstr;
443 friend class UnboxedDoubleBinaryOpInstr; 443 friend class UnboxedDoubleBinaryOpInstr;
444 friend class MathSqrtInstr; 444 friend class MathSqrtInstr;
445 friend class CheckClassInstr; 445 friend class CheckClassInstr;
446 friend class CheckSmiInstr; 446 friend class CheckSmiInstr;
447 friend class CheckArrayBoundInstr; 447 friend class CheckArrayBoundInstr;
448 friend class CheckBoundInstr;
449 friend class CheckEitherNonSmiInstr; 448 friend class CheckEitherNonSmiInstr;
450 friend class LICM; 449 friend class LICM;
451 450
452 intptr_t deopt_id_; 451 intptr_t deopt_id_;
453 intptr_t lifetime_position_; // Position used by register allocator. 452 intptr_t lifetime_position_; // Position used by register allocator.
454 Instruction* previous_; 453 Instruction* previous_;
455 Instruction* next_; 454 Instruction* next_;
456 Environment* env_; 455 Environment* env_;
457 DISALLOW_COPY_AND_ASSIGN(Instruction); 456 DISALLOW_COPY_AND_ASSIGN(Instruction);
458 }; 457 };
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 class StaticCallInstr : public TemplateDefinition<0> { 1989 class StaticCallInstr : public TemplateDefinition<0> {
1991 public: 1990 public:
1992 StaticCallInstr(intptr_t token_pos, 1991 StaticCallInstr(intptr_t token_pos,
1993 const Function& function, 1992 const Function& function,
1994 const Array& argument_names, 1993 const Array& argument_names,
1995 ZoneGrowableArray<PushArgumentInstr*>* arguments) 1994 ZoneGrowableArray<PushArgumentInstr*>* arguments)
1996 : token_pos_(token_pos), 1995 : token_pos_(token_pos),
1997 function_(function), 1996 function_(function),
1998 argument_names_(argument_names), 1997 argument_names_(argument_names),
1999 arguments_(arguments), 1998 arguments_(arguments),
2000 result_cid_(kDynamicCid), 1999 result_cid_(kDynamicCid) {
2001 is_known_constructor_(false) {
2002 ASSERT(function.IsZoneHandle()); 2000 ASSERT(function.IsZoneHandle());
2003 ASSERT(argument_names.IsZoneHandle()); 2001 ASSERT(argument_names.IsZoneHandle());
2004 } 2002 }
2005 2003
2006 DECLARE_INSTRUCTION(StaticCall) 2004 DECLARE_INSTRUCTION(StaticCall)
2007 virtual RawAbstractType* CompileType() const; 2005 virtual RawAbstractType* CompileType() const;
2008 2006
2009 // Accessors forwarded to the AST node. 2007 // Accessors forwarded to the AST node.
2010 const Function& function() const { return function_; } 2008 const Function& function() const { return function_; }
2011 const Array& argument_names() const { return argument_names_; } 2009 const Array& argument_names() const { return argument_names_; }
2012 intptr_t token_pos() const { return token_pos_; } 2010 intptr_t token_pos() const { return token_pos_; }
2013 2011
2014 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2012 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2015 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2013 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2016 return (*arguments_)[index]; 2014 return (*arguments_)[index];
2017 } 2015 }
2018 2016
2019 virtual void PrintOperandsTo(BufferFormatter* f) const; 2017 virtual void PrintOperandsTo(BufferFormatter* f) const;
2020 2018
2021 virtual bool CanDeoptimize() const { return true; } 2019 virtual bool CanDeoptimize() const { return true; }
2022 virtual intptr_t ResultCid() const { return result_cid_; } 2020 virtual intptr_t ResultCid() const { return result_cid_; }
2023 void set_result_cid(intptr_t value) { result_cid_ = value; } 2021 void set_result_cid(intptr_t value) { result_cid_ = value; }
2024 2022
2025 bool is_known_constructor() const { return is_known_constructor_; }
2026 void set_is_known_constructor(bool is_known_constructor) {
2027 is_known_constructor_ = is_known_constructor;
2028 }
2029
2030 private: 2023 private:
2031 const intptr_t token_pos_; 2024 const intptr_t token_pos_;
2032 const Function& function_; 2025 const Function& function_;
2033 const Array& argument_names_; 2026 const Array& argument_names_;
2034 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2027 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2035 intptr_t result_cid_; // For some library functions we know the result. 2028 intptr_t result_cid_; // For some library functions we know the result.
2036 2029
2037 // Some library constructors have known semantics.
2038 bool is_known_constructor_;
2039
2040 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 2030 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
2041 }; 2031 };
2042 2032
2043 2033
2044 class LoadLocalInstr : public TemplateDefinition<0> { 2034 class LoadLocalInstr : public TemplateDefinition<0> {
2045 public: 2035 public:
2046 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) 2036 LoadLocalInstr(const LocalVariable& local, intptr_t context_level)
2047 : local_(local), 2037 : local_(local),
2048 context_level_(context_level) { } 2038 context_level_(context_level) { }
2049 2039
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2871 public: 2861 public:
2872 MathSqrtInstr(Value* value, StaticCallInstr* instance_call) { 2862 MathSqrtInstr(Value* value, StaticCallInstr* instance_call) {
2873 ASSERT(value != NULL); 2863 ASSERT(value != NULL);
2874 inputs_[0] = value; 2864 inputs_[0] = value;
2875 deopt_id_ = instance_call->deopt_id(); 2865 deopt_id_ = instance_call->deopt_id();
2876 } 2866 }
2877 2867
2878 Value* value() const { return inputs_[0]; } 2868 Value* value() const { return inputs_[0]; }
2879 2869
2880 virtual bool CanDeoptimize() const { return false; } 2870 virtual bool CanDeoptimize() const { return false; }
2881 virtual bool AffectedBySideEffect() const { return false; } 2871 virtual bool HasSideEffect() const { return false; }
Florian Schneider 2012/09/12 12:39:28 Probably need to rebase to make sure it compiles.
2882 2872
2883 virtual bool AttributesEqual(Definition* other) const { 2873 virtual bool AttributesEqual(Definition* other) const {
2884 return true; 2874 return true;
2885 } 2875 }
2886 2876
2887 // The output is not an instance but when it is boxed it becomes double. 2877 // The output is not an instance but when it is boxed it becomes double.
2888 virtual intptr_t ResultCid() const { return kDoubleCid; } 2878 virtual intptr_t ResultCid() const { return kDoubleCid; }
2889 2879
2890 virtual Representation representation() const { 2880 virtual Representation representation() const {
2891 return kUnboxedDouble; 2881 return kUnboxedDouble;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 3249
3260 virtual bool AttributesEqual(Definition* other) const; 3250 virtual bool AttributesEqual(Definition* other) const;
3261 3251
3262 virtual bool AffectedBySideEffect() const { return false; } 3252 virtual bool AffectedBySideEffect() const { return false; }
3263 3253
3264 Value* array() const { return inputs_[0]; } 3254 Value* array() const { return inputs_[0]; }
3265 Value* index() const { return inputs_[1]; } 3255 Value* index() const { return inputs_[1]; }
3266 3256
3267 intptr_t array_type() const { return array_type_; } 3257 intptr_t array_type() const { return array_type_; }
3268 3258
3269 virtual Definition* Canonicalize();
3270
3271 private: 3259 private:
3272 intptr_t array_type_; 3260 intptr_t array_type_;
3273 3261
3274 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 3262 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
3275 }; 3263 };
3276 3264
3277 3265
3278 class CheckBoundInstr : public TemplateDefinition<2> {
3279 public:
3280 CheckBoundInstr(Value* length,
3281 Value* index,
3282 intptr_t deopt_id) {
3283 ASSERT(length != NULL);
3284 ASSERT(index != NULL);
3285 inputs_[0] = length;
3286 inputs_[1] = index;
3287 deopt_id_ = deopt_id;
3288 }
3289
3290 DECLARE_INSTRUCTION(CheckBound)
3291 virtual RawAbstractType* CompileType() const;
3292
3293 virtual bool CanDeoptimize() const { return true; }
3294 virtual intptr_t ResultCid() const { return kIllegalCid; }
3295
3296 virtual bool AttributesEqual(Definition* other) const {
3297 return true;
3298 }
3299
3300 virtual bool AffectedBySideEffect() const { return false; }
3301
3302 Value* length() const { return inputs_[0]; }
3303 Value* index() const { return inputs_[1]; }
3304
3305 private:
3306 DISALLOW_COPY_AND_ASSIGN(CheckBoundInstr);
3307 };
3308
3309
3310 #undef DECLARE_INSTRUCTION 3266 #undef DECLARE_INSTRUCTION
3311 3267
3312 class Environment : public ZoneAllocated { 3268 class Environment : public ZoneAllocated {
3313 public: 3269 public:
3314 // Iterate the non-NULL values in the innermost level of an environment. 3270 // Iterate the non-NULL values in the innermost level of an environment.
3315 class ShallowIterator : public ValueObject { 3271 class ShallowIterator : public ValueObject {
3316 public: 3272 public:
3317 explicit ShallowIterator(Environment* environment) 3273 explicit ShallowIterator(Environment* environment)
3318 : environment_(environment), index_(0) { } 3274 : environment_(environment), index_(0) { }
3319 3275
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3488 ForwardInstructionIterator* current_iterator_; 3444 ForwardInstructionIterator* current_iterator_;
3489 3445
3490 private: 3446 private:
3491 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 3447 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
3492 }; 3448 };
3493 3449
3494 3450
3495 } // namespace dart 3451 } // namespace dart
3496 3452
3497 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 3453 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698