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

Side by Side Diff: src/hydrogen-instructions.h

Issue 15861009: Tag smi-constants as smi. This also fixes code that copies holes into arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 6 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 virtual HType CalculateInferredType(); 3220 virtual HType CalculateInferredType();
3221 bool IsInteger() { return handle()->IsSmi(); } 3221 bool IsInteger() { return handle()->IsSmi(); }
3222 HConstant* CopyToRepresentation(Representation r, Zone* zone) const; 3222 HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
3223 HConstant* CopyToTruncatedInt32(Zone* zone) const; 3223 HConstant* CopyToTruncatedInt32(Zone* zone) const;
3224 bool HasInteger32Value() const { return has_int32_value_; } 3224 bool HasInteger32Value() const { return has_int32_value_; }
3225 int32_t Integer32Value() const { 3225 int32_t Integer32Value() const {
3226 ASSERT(HasInteger32Value()); 3226 ASSERT(HasInteger32Value());
3227 return int32_value_; 3227 return int32_value_;
3228 } 3228 }
3229 bool HasSmiValue() const { 3229 bool HasSmiValue() const {
3230 return HasInteger32Value() && Smi::IsValid(Integer32Value()); 3230 return has_smi_value_;
3231 } 3231 }
3232 bool HasDoubleValue() const { return has_double_value_; } 3232 bool HasDoubleValue() const { return has_double_value_; }
3233 double DoubleValue() const { 3233 double DoubleValue() const {
3234 ASSERT(HasDoubleValue()); 3234 ASSERT(HasDoubleValue());
3235 return double_value_; 3235 return double_value_;
3236 } 3236 }
3237 bool IsTheHole() const { 3237 bool IsTheHole() const {
3238 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) { 3238 if (HasDoubleValue() && FixedDoubleArray::is_the_hole_nan(double_value_)) {
3239 return true; 3239 return true;
3240 } 3240 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 // constant is non-numeric, handle_ always points to a valid 3320 // constant is non-numeric, handle_ always points to a valid
3321 // constant HeapObject. 3321 // constant HeapObject.
3322 Handle<Object> handle_; 3322 Handle<Object> handle_;
3323 UniqueValueId unique_id_; 3323 UniqueValueId unique_id_;
3324 3324
3325 // We store the HConstant in the most specific form safely possible. 3325 // We store the HConstant in the most specific form safely possible.
3326 // The two flags, has_int32_value_ and has_double_value_ tell us if 3326 // The two flags, has_int32_value_ and has_double_value_ tell us if
3327 // int32_value_ and double_value_ hold valid, safe representations 3327 // int32_value_ and double_value_ hold valid, safe representations
3328 // of the constant. has_int32_value_ implies has_double_value_ but 3328 // of the constant. has_int32_value_ implies has_double_value_ but
3329 // not the converse. 3329 // not the converse.
3330 bool has_smi_value_ : 1;
3330 bool has_int32_value_ : 1; 3331 bool has_int32_value_ : 1;
3331 bool has_double_value_ : 1; 3332 bool has_double_value_ : 1;
3332 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType. 3333 bool is_internalized_string_ : 1; // TODO(yangguo): make this part of HType.
3333 bool is_not_in_new_space_ : 1; 3334 bool is_not_in_new_space_ : 1;
3334 bool boolean_value_ : 1; 3335 bool boolean_value_ : 1;
3335 int32_t int32_value_; 3336 int32_t int32_value_;
3336 double double_value_; 3337 double double_value_;
3337 HType type_from_value_; 3338 HType type_from_value_;
3338 }; 3339 };
3339 3340
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3388 3389
3389 virtual Representation observed_input_representation(int index) { 3390 virtual Representation observed_input_representation(int index) {
3390 if (index == 0) return Representation::Tagged(); 3391 if (index == 0) return Representation::Tagged();
3391 return observed_input_representation_[index - 1]; 3392 return observed_input_representation_[index - 1];
3392 } 3393 }
3393 3394
3394 virtual void InferRepresentation(HInferRepresentation* h_infer); 3395 virtual void InferRepresentation(HInferRepresentation* h_infer);
3395 virtual Representation RepresentationFromInputs(); 3396 virtual Representation RepresentationFromInputs();
3396 virtual void AssumeRepresentation(Representation r); 3397 virtual void AssumeRepresentation(Representation r);
3397 3398
3399 virtual void UpdateRepresentation(Representation new_rep,
3400 HInferRepresentation* h_infer,
3401 const char* reason) {
3402 // By default, binary operations don't handle Smis.
3403 if (new_rep.IsSmi()) {
3404 new_rep = Representation::Integer32();
3405 }
3406 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3407 }
3408
3398 virtual bool IsCommutative() const { return false; } 3409 virtual bool IsCommutative() const { return false; }
3399 3410
3400 virtual void PrintDataTo(StringStream* stream); 3411 virtual void PrintDataTo(StringStream* stream);
3401 3412
3402 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) 3413 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
3403 3414
3404 private: 3415 private:
3405 bool IgnoreObservedOutputRepresentation(Representation current_rep); 3416 bool IgnoreObservedOutputRepresentation(Representation current_rep);
3406 3417
3407 Representation observed_input_representation_[2]; 3418 Representation observed_input_representation_[2];
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 3560
3550 3561
3551 class HBoundsCheck: public HTemplateInstruction<2> { 3562 class HBoundsCheck: public HTemplateInstruction<2> {
3552 public: 3563 public:
3553 // Normally HBoundsCheck should be created using the 3564 // Normally HBoundsCheck should be created using the
3554 // HGraphBuilder::AddBoundsCheck() helper. 3565 // HGraphBuilder::AddBoundsCheck() helper.
3555 // However when building stubs, where we know that the arguments are Int32, 3566 // However when building stubs, where we know that the arguments are Int32,
3556 // it makes sense to invoke this constructor directly. 3567 // it makes sense to invoke this constructor directly.
3557 HBoundsCheck(HValue* index, 3568 HBoundsCheck(HValue* index,
3558 HValue* length, 3569 HValue* length,
3559 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY, 3570 BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY)
3560 Representation r = Representation::None())
3561 : key_mode_(key_mode), skip_check_(false), 3571 : key_mode_(key_mode), skip_check_(false),
3562 base_(NULL), offset_(0), scale_(0), 3572 base_(NULL), offset_(0), scale_(0),
3563 responsibility_direction_(DIRECTION_NONE) { 3573 responsibility_direction_(DIRECTION_NONE) {
3564 SetOperandAt(0, index); 3574 SetOperandAt(0, index);
3565 SetOperandAt(1, length); 3575 SetOperandAt(1, length);
3566 if (r.IsNone()) { 3576 SetFlag(kFlexibleRepresentation);
3567 // In the normal compilation pipeline the representation is flexible
3568 // (see InferRepresentation).
3569 SetFlag(kFlexibleRepresentation);
3570 } else {
3571 // When compiling stubs we want to set the representation explicitly
3572 // so the compilation pipeline can skip the HInferRepresentation phase.
3573 set_representation(r);
3574 }
3575 SetFlag(kUseGVN); 3577 SetFlag(kUseGVN);
3576 } 3578 }
3577 3579
3578 bool skip_check() { return skip_check_; } 3580 bool skip_check() { return skip_check_; }
3579 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } 3581 void set_skip_check(bool skip_check) { skip_check_ = skip_check; }
3580 HValue* base() { return base_; } 3582 HValue* base() { return base_; }
3581 int offset() { return offset_; } 3583 int offset() { return offset_; }
3582 int scale() { return scale_; } 3584 int scale() { return scale_; }
3583 bool index_can_increase() { 3585 bool index_can_increase() {
3584 return (responsibility_direction_ & DIRECTION_LOWER) == 0; 3586 return (responsibility_direction_ & DIRECTION_LOWER) == 0;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3711 } else { 3713 } else {
3712 SetAllSideEffects(); 3714 SetAllSideEffects();
3713 ClearFlag(kUseGVN); 3715 ClearFlag(kUseGVN);
3714 } 3716 }
3715 } 3717 }
3716 3718
3717 virtual void UpdateRepresentation(Representation new_rep, 3719 virtual void UpdateRepresentation(Representation new_rep,
3718 HInferRepresentation* h_infer, 3720 HInferRepresentation* h_infer,
3719 const char* reason) { 3721 const char* reason) {
3720 // We only generate either int32 or generic tagged bitwise operations. 3722 // We only generate either int32 or generic tagged bitwise operations.
3721 if (new_rep.IsDouble()) new_rep = Representation::Integer32(); 3723 if (new_rep.IsSmi() || new_rep.IsDouble()) {
3724 new_rep = Representation::Integer32();
3725 }
3722 HValue::UpdateRepresentation(new_rep, h_infer, reason); 3726 HValue::UpdateRepresentation(new_rep, h_infer, reason);
3723 } 3727 }
3724 3728
3725 virtual void initialize_output_representation(Representation observed) { 3729 virtual void initialize_output_representation(Representation observed) {
3726 if (observed.IsDouble()) observed = Representation::Integer32(); 3730 if (observed.IsDouble()) observed = Representation::Integer32();
3727 HBinaryOperation::initialize_output_representation(observed); 3731 HBinaryOperation::initialize_output_representation(observed);
3728 } 3732 }
3729 3733
3730 virtual HType CalculateInferredType(); 3734 virtual HType CalculateInferredType();
3731 3735
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after
6518 virtual bool IsDeletable() const { return true; } 6522 virtual bool IsDeletable() const { return true; }
6519 }; 6523 };
6520 6524
6521 6525
6522 #undef DECLARE_INSTRUCTION 6526 #undef DECLARE_INSTRUCTION
6523 #undef DECLARE_CONCRETE_INSTRUCTION 6527 #undef DECLARE_CONCRETE_INSTRUCTION
6524 6528
6525 } } // namespace v8::internal 6529 } } // namespace v8::internal
6526 6530
6527 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 6531 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698