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

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

Issue 2974633003: Option to truncate integers to 64 bits, part 1 (core VM changes) (Closed)
Patch Set: Merged 2 flags into 1 (--limit-ints-to-64-bits) Created 3 years, 5 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 RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_
6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 6 #define RUNTIME_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/flags.h"
10 #include "vm/growable_array.h" 11 #include "vm/growable_array.h"
11 #include "vm/locations.h" 12 #include "vm/locations.h"
12 #include "vm/method_recognizer.h" 13 #include "vm/method_recognizer.h"
13 #include "vm/object.h" 14 #include "vm/object.h"
14 #include "vm/parser.h" 15 #include "vm/parser.h"
15 #include "vm/token_position.h" 16 #include "vm/token_position.h"
16 17
17 namespace dart { 18 namespace dart {
18 19
19 class BitVector; 20 class BitVector;
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 724
724 // Call instructions override this function and return the number of 725 // Call instructions override this function and return the number of
725 // pushed arguments. 726 // pushed arguments.
726 virtual intptr_t ArgumentCount() const { return 0; } 727 virtual intptr_t ArgumentCount() const { return 0; }
727 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { 728 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
728 UNREACHABLE(); 729 UNREACHABLE();
729 return NULL; 730 return NULL;
730 } 731 }
731 inline Definition* ArgumentAt(intptr_t index) const; 732 inline Definition* ArgumentAt(intptr_t index) const;
732 733
733 // Returns true, if this instruction can deoptimize with its current imputs. 734 // Returns true, if this instruction can deoptimize with its current inputs.
734 // This property can change if we add or remove redefinitions that constrain 735 // This property can change if we add or remove redefinitions that constrain
735 // the type or the range of input operands during compilation. 736 // the type or the range of input operands during compilation.
736 virtual bool ComputeCanDeoptimize() const = 0; 737 virtual bool ComputeCanDeoptimize() const = 0;
737 738
738 // Once we removed the deopt environment, we assume that this 739 // Once we removed the deopt environment, we assume that this
739 // instruction can't deoptimize. 740 // instruction can't deoptimize.
740 bool CanDeoptimize() const { return env() != NULL && ComputeCanDeoptimize(); } 741 bool CanDeoptimize() const { return env() != NULL && ComputeCanDeoptimize(); }
741 742
742 // Visiting support. 743 // Visiting support.
743 virtual void Accept(FlowGraphVisitor* visitor) = 0; 744 virtual void Accept(FlowGraphVisitor* visitor) = 0;
(...skipping 6428 matching lines...) Expand 10 before | Expand all | Expand 10 after
7172 DISALLOW_COPY_AND_ASSIGN(ShiftUint32OpInstr); 7173 DISALLOW_COPY_AND_ASSIGN(ShiftUint32OpInstr);
7173 }; 7174 };
7174 7175
7175 7176
7176 class BinaryMintOpInstr : public BinaryIntegerOpInstr { 7177 class BinaryMintOpInstr : public BinaryIntegerOpInstr {
7177 public: 7178 public:
7178 BinaryMintOpInstr(Token::Kind op_kind, 7179 BinaryMintOpInstr(Token::Kind op_kind,
7179 Value* left, 7180 Value* left,
7180 Value* right, 7181 Value* right,
7181 intptr_t deopt_id) 7182 intptr_t deopt_id)
7182 : BinaryIntegerOpInstr(op_kind, left, right, deopt_id) {} 7183 : BinaryIntegerOpInstr(op_kind, left, right, deopt_id) {
7184 if (FLAG_limit_ints_to_64_bits) {
7185 mark_truncating();
7186 }
7187 }
7183 7188
7184 virtual bool ComputeCanDeoptimize() const { 7189 virtual bool ComputeCanDeoptimize() const {
7185 return (can_overflow() && 7190 switch (op_kind()) {
7186 ((op_kind() == Token::kADD) || (op_kind() == Token::kSUB))) || 7191 case Token::kADD:
7187 (op_kind() == Token::kMUL); // Deopt if inputs are not int32. 7192 case Token::kSUB:
7193 return can_overflow();
7194 case Token::kMUL:
7195 // Note that ARM64 does not support operations with unboxed mints,
7196 // so it is not handled here.
7197 #if defined(TARGET_ARCH_X64)
7198 return can_overflow(); // Deopt if overflow.
7199 #else
7200 // IA32, ARM
7201 return true; // Deopt if inputs are not int32.
7202 #endif
7203 default:
7204 return false;
7205 }
7188 } 7206 }
7189 7207
7190 virtual Representation representation() const { return kUnboxedMint; } 7208 virtual Representation representation() const { return kUnboxedMint; }
7191 7209
7192 virtual Representation RequiredInputRepresentation(intptr_t idx) const { 7210 virtual Representation RequiredInputRepresentation(intptr_t idx) const {
7193 ASSERT((idx == 0) || (idx == 1)); 7211 ASSERT((idx == 0) || (idx == 1));
7194 return kUnboxedMint; 7212 return kUnboxedMint;
7195 } 7213 }
7196 7214
7197 virtual void InferRange(RangeAnalysis* analysis, Range* range); 7215 virtual void InferRange(RangeAnalysis* analysis, Range* range);
7198 virtual CompileType ComputeType() const; 7216 virtual CompileType ComputeType() const;
7199 7217
7200 DECLARE_INSTRUCTION(BinaryMintOp) 7218 DECLARE_INSTRUCTION(BinaryMintOp)
7201 7219
7202 private: 7220 private:
7203 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr); 7221 DISALLOW_COPY_AND_ASSIGN(BinaryMintOpInstr);
7204 }; 7222 };
7205 7223
7206 7224
7207 class ShiftMintOpInstr : public BinaryIntegerOpInstr { 7225 class ShiftMintOpInstr : public BinaryIntegerOpInstr {
7208 public: 7226 public:
7209 ShiftMintOpInstr(Token::Kind op_kind, 7227 ShiftMintOpInstr(Token::Kind op_kind,
7210 Value* left, 7228 Value* left,
7211 Value* right, 7229 Value* right,
7212 intptr_t deopt_id) 7230 intptr_t deopt_id)
7213 : BinaryIntegerOpInstr(op_kind, left, right, deopt_id), 7231 : BinaryIntegerOpInstr(op_kind, left, right, deopt_id),
7214 shift_range_(NULL) { 7232 shift_range_(NULL) {
7215 ASSERT((op_kind == Token::kSHR) || (op_kind == Token::kSHL)); 7233 ASSERT((op_kind == Token::kSHR) || (op_kind == Token::kSHL));
7234 if (FLAG_limit_ints_to_64_bits) {
7235 mark_truncating();
7236 }
7216 } 7237 }
7217 7238
7218 Range* shift_range() const { return shift_range_; } 7239 Range* shift_range() const { return shift_range_; }
7219 7240
7220 virtual bool ComputeCanDeoptimize() const { 7241 virtual bool ComputeCanDeoptimize() const {
7221 return has_shift_count_check() || 7242 return has_shift_count_check() ||
7222 (can_overflow() && (op_kind() == Token::kSHL)); 7243 (can_overflow() && (op_kind() == Token::kSHL));
7223 } 7244 }
7224 7245
7225 virtual Representation representation() const { return kUnboxedMint; } 7246 virtual Representation representation() const { return kUnboxedMint; }
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
8256 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ 8277 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \
8257 UNIMPLEMENTED(); \ 8278 UNIMPLEMENTED(); \
8258 return NULL; \ 8279 return NULL; \
8259 } \ 8280 } \
8260 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8281 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8261 8282
8262 8283
8263 } // namespace dart 8284 } // namespace dart
8264 8285
8265 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ 8286 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698