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

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

Issue 11273111: Allow bound check elimination to eliminate checks when both array length and index boundaries are e… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Florian's comments Created 8 years, 1 month 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/hash_map_test.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 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 1600
1601 static RangeBoundary OverflowedMaxSmi() { 1601 static RangeBoundary OverflowedMaxSmi() {
1602 return FromConstant(Smi::kMaxValue + 1); 1602 return FromConstant(Smi::kMaxValue + 1);
1603 } 1603 }
1604 1604
1605 static RangeBoundary Min(RangeBoundary a, RangeBoundary b); 1605 static RangeBoundary Min(RangeBoundary a, RangeBoundary b);
1606 1606
1607 static RangeBoundary Max(RangeBoundary a, RangeBoundary b); 1607 static RangeBoundary Max(RangeBoundary a, RangeBoundary b);
1608 1608
1609 bool Overflowed() const { 1609 bool Overflowed() const {
1610 return !Smi::IsValid(value()); 1610 return IsConstant() && !Smi::IsValid(value());
1611 } 1611 }
1612 1612
1613 RangeBoundary Clamp() const { 1613 RangeBoundary Clamp() const {
1614 if (IsConstant()) { 1614 if (IsConstant()) {
1615 if (value() < Smi::kMinValue) return MinSmi(); 1615 if (value() < Smi::kMinValue) return MinSmi();
1616 if (value() > Smi::kMaxValue) return MaxSmi(); 1616 if (value() > Smi::kMaxValue) return MaxSmi();
1617 } 1617 }
1618 return *this; 1618 return *this;
1619 } 1619 }
1620 1620
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 class StaticCallInstr : public TemplateDefinition<0> { 2360 class StaticCallInstr : public TemplateDefinition<0> {
2361 public: 2361 public:
2362 StaticCallInstr(intptr_t token_pos, 2362 StaticCallInstr(intptr_t token_pos,
2363 const Function& function, 2363 const Function& function,
2364 const Array& argument_names, 2364 const Array& argument_names,
2365 ZoneGrowableArray<PushArgumentInstr*>* arguments) 2365 ZoneGrowableArray<PushArgumentInstr*>* arguments)
2366 : token_pos_(token_pos), 2366 : token_pos_(token_pos),
2367 function_(function), 2367 function_(function),
2368 argument_names_(argument_names), 2368 argument_names_(argument_names),
2369 arguments_(arguments), 2369 arguments_(arguments),
2370 result_cid_(kDynamicCid) { 2370 result_cid_(kDynamicCid),
2371 is_known_constructor_(false) {
2371 ASSERT(function.IsZoneHandle()); 2372 ASSERT(function.IsZoneHandle());
2372 ASSERT(argument_names.IsZoneHandle()); 2373 ASSERT(argument_names.IsZoneHandle());
2373 } 2374 }
2374 2375
2375 DECLARE_INSTRUCTION(StaticCall) 2376 DECLARE_INSTRUCTION(StaticCall)
2376 virtual RawAbstractType* CompileType() const; 2377 virtual RawAbstractType* CompileType() const;
2377 2378
2378 // Accessors forwarded to the AST node. 2379 // Accessors forwarded to the AST node.
2379 const Function& function() const { return function_; } 2380 const Function& function() const { return function_; }
2380 const Array& argument_names() const { return argument_names_; } 2381 const Array& argument_names() const { return argument_names_; }
2381 intptr_t token_pos() const { return token_pos_; } 2382 intptr_t token_pos() const { return token_pos_; }
2382 2383
2383 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2384 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2384 PushArgumentInstr* ArgumentAt(intptr_t index) const { 2385 PushArgumentInstr* ArgumentAt(intptr_t index) const {
2385 return (*arguments_)[index]; 2386 return (*arguments_)[index];
2386 } 2387 }
2387 2388
2388 virtual void PrintOperandsTo(BufferFormatter* f) const; 2389 virtual void PrintOperandsTo(BufferFormatter* f) const;
2389 2390
2390 virtual bool CanDeoptimize() const { return true; } 2391 virtual bool CanDeoptimize() const { return true; }
2391 2392
2392 virtual bool HasSideEffect() const { return true; } 2393 virtual bool HasSideEffect() const { return true; }
2393 2394
2394 virtual intptr_t ResultCid() const { return result_cid_; } 2395 virtual intptr_t ResultCid() const { return result_cid_; }
2395 void set_result_cid(intptr_t value) { result_cid_ = value; } 2396 void set_result_cid(intptr_t value) { result_cid_ = value; }
2396 2397
2398 bool is_known_constructor() const { return is_known_constructor_; }
2399 void set_is_known_constructor(bool is_known_constructor) {
2400 is_known_constructor_ = is_known_constructor;
2401 }
2402
2397 private: 2403 private:
2398 const intptr_t token_pos_; 2404 const intptr_t token_pos_;
2399 const Function& function_; 2405 const Function& function_;
2400 const Array& argument_names_; 2406 const Array& argument_names_;
2401 ZoneGrowableArray<PushArgumentInstr*>* arguments_; 2407 ZoneGrowableArray<PushArgumentInstr*>* arguments_;
2402 intptr_t result_cid_; // For some library functions we know the result. 2408 intptr_t result_cid_; // For some library functions we know the result.
2403 2409
2410 // Some library constructors have known semantics.
2411 bool is_known_constructor_;
2412
2413
2404 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr); 2414 DISALLOW_COPY_AND_ASSIGN(StaticCallInstr);
2405 }; 2415 };
2406 2416
2407 2417
2408 class LoadLocalInstr : public TemplateDefinition<0> { 2418 class LoadLocalInstr : public TemplateDefinition<0> {
2409 public: 2419 public:
2410 LoadLocalInstr(const LocalVariable& local, intptr_t context_level) 2420 LoadLocalInstr(const LocalVariable& local, intptr_t context_level)
2411 : local_(local), 2421 : local_(local),
2412 context_level_(context_level) { } 2422 context_level_(context_level) { }
2413 2423
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 3959
3950 virtual bool AttributesEqual(Instruction* other) const; 3960 virtual bool AttributesEqual(Instruction* other) const;
3951 3961
3952 virtual bool AffectedBySideEffect() const { return false; } 3962 virtual bool AffectedBySideEffect() const { return false; }
3953 3963
3954 Value* array() const { return inputs_[0]; } 3964 Value* array() const { return inputs_[0]; }
3955 Value* index() const { return inputs_[1]; } 3965 Value* index() const { return inputs_[1]; }
3956 3966
3957 intptr_t array_type() const { return array_type_; } 3967 intptr_t array_type() const { return array_type_; }
3958 3968
3959 bool IsRedundant(); 3969 bool IsRedundant(RangeBoundary length);
3960 3970
3961 private: 3971 private:
3962 intptr_t array_type_; 3972 intptr_t array_type_;
3963 3973
3964 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr); 3974 DISALLOW_COPY_AND_ASSIGN(CheckArrayBoundInstr);
3965 }; 3975 };
3966 3976
3967 3977
3968 #undef DECLARE_INSTRUCTION 3978 #undef DECLARE_INSTRUCTION
3969 3979
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
4172 ForwardInstructionIterator* current_iterator_; 4182 ForwardInstructionIterator* current_iterator_;
4173 4183
4174 private: 4184 private:
4175 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 4185 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
4176 }; 4186 };
4177 4187
4178 4188
4179 } // namespace dart 4189 } // namespace dart
4180 4190
4181 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 4191 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/hash_map_test.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698