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

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

Issue 71163006: Merge bleeding_edge r17376:17693. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Fix all.gyp Created 7 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 | « src/hydrogen-instructions.h ('k') | src/hydrogen-load-elimination.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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } 1248 }
1249 1249
1250 1250
1251 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { 1251 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
1252 return arg1->representation().IsSpecialization() && 1252 return arg1->representation().IsSpecialization() &&
1253 arg2->EqualsInteger32Constant(identity); 1253 arg2->EqualsInteger32Constant(identity);
1254 } 1254 }
1255 1255
1256 1256
1257 HValue* HAdd::Canonicalize() { 1257 HValue* HAdd::Canonicalize() {
1258 if (IsIdentityOperation(left(), right(), 0)) return left(); 1258 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0
1259 if (IsIdentityOperation(right(), left(), 0)) return right(); 1259 if (IsIdentityOperation(left(), right(), 0) &&
1260 !left()->representation().IsDouble()) { // Left could be -0.
1261 return left();
1262 }
1263 if (IsIdentityOperation(right(), left(), 0) &&
1264 !left()->representation().IsDouble()) { // Right could be -0.
1265 return right();
1266 }
1260 return this; 1267 return this;
1261 } 1268 }
1262 1269
1263 1270
1264 HValue* HSub::Canonicalize() { 1271 HValue* HSub::Canonicalize() {
1265 if (IsIdentityOperation(left(), right(), 0)) return left(); 1272 if (IsIdentityOperation(left(), right(), 0)) return left();
1266 return this; 1273 return this;
1267 } 1274 }
1268 1275
1269 1276
(...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 : new(zone) Range(); 2849 : new(zone) Range();
2843 result->Shl(c->Integer32Value()); 2850 result->Shl(c->Integer32Value());
2844 return result; 2851 return result;
2845 } 2852 }
2846 } 2853 }
2847 return HValue::InferRange(zone); 2854 return HValue::InferRange(zone);
2848 } 2855 }
2849 2856
2850 2857
2851 Range* HLoadNamedField::InferRange(Zone* zone) { 2858 Range* HLoadNamedField::InferRange(Zone* zone) {
2852 if (access().representation().IsByte()) { 2859 if (access().representation().IsInteger8()) {
2853 return new(zone) Range(0, 255); 2860 return new(zone) Range(kMinInt8, kMaxInt8);
2861 }
2862 if (access().representation().IsUInteger8()) {
2863 return new(zone) Range(kMinUInt8, kMaxUInt8);
2864 }
2865 if (access().representation().IsInteger16()) {
2866 return new(zone) Range(kMinInt16, kMaxInt16);
2867 }
2868 if (access().representation().IsUInteger16()) {
2869 return new(zone) Range(kMinUInt16, kMaxUInt16);
2854 } 2870 }
2855 if (access().IsStringLength()) { 2871 if (access().IsStringLength()) {
2856 return new(zone) Range(0, String::kMaxLength); 2872 return new(zone) Range(0, String::kMaxLength);
2857 } 2873 }
2858 return HValue::InferRange(zone); 2874 return HValue::InferRange(zone);
2859 } 2875 }
2860 2876
2861 2877
2862 Range* HLoadKeyed::InferRange(Zone* zone) { 2878 Range* HLoadKeyed::InferRange(Zone* zone) {
2863 switch (elements_kind()) { 2879 switch (elements_kind()) {
2880 case EXTERNAL_BYTE_ELEMENTS:
2881 return new(zone) Range(kMinInt8, kMaxInt8);
2882 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2864 case EXTERNAL_PIXEL_ELEMENTS: 2883 case EXTERNAL_PIXEL_ELEMENTS:
2865 return new(zone) Range(0, 255); 2884 return new(zone) Range(kMinUInt8, kMaxUInt8);
2866 case EXTERNAL_BYTE_ELEMENTS:
2867 return new(zone) Range(-128, 127);
2868 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2869 return new(zone) Range(0, 255);
2870 case EXTERNAL_SHORT_ELEMENTS: 2885 case EXTERNAL_SHORT_ELEMENTS:
2871 return new(zone) Range(-32768, 32767); 2886 return new(zone) Range(kMinInt16, kMaxInt16);
2872 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 2887 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
2873 return new(zone) Range(0, 65535); 2888 return new(zone) Range(kMinUInt16, kMaxUInt16);
2874 default: 2889 default:
2875 return HValue::InferRange(zone); 2890 return HValue::InferRange(zone);
2876 } 2891 }
2877 } 2892 }
2878 2893
2879 2894
2880 void HCompareGeneric::PrintDataTo(StringStream* stream) { 2895 void HCompareGeneric::PrintDataTo(StringStream* stream) {
2881 stream->Add(Token::Name(token())); 2896 stream->Add(Token::Name(token()));
2882 stream->Add(" "); 2897 stream->Add(" ");
2883 HBinaryOperation::PrintDataTo(stream); 2898 HBinaryOperation::PrintDataTo(stream);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 return false; 2937 return false;
2923 } 2938 }
2924 2939
2925 2940
2926 void HCompareHoleAndBranch::InferRepresentation( 2941 void HCompareHoleAndBranch::InferRepresentation(
2927 HInferRepresentationPhase* h_infer) { 2942 HInferRepresentationPhase* h_infer) {
2928 ChangeRepresentation(value()->representation()); 2943 ChangeRepresentation(value()->representation());
2929 } 2944 }
2930 2945
2931 2946
2947 bool HCompareMinusZeroAndBranch::KnownSuccessorBlock(HBasicBlock** block) {
2948 if (value()->representation().IsSmiOrInteger32()) {
2949 // A Smi or Integer32 cannot contain minus zero.
2950 *block = SecondSuccessor();
2951 return true;
2952 }
2953 *block = NULL;
2954 return false;
2955 }
2956
2957
2958 void HCompareMinusZeroAndBranch::InferRepresentation(
2959 HInferRepresentationPhase* h_infer) {
2960 ChangeRepresentation(value()->representation());
2961 }
2962
2963
2964
2932 void HGoto::PrintDataTo(StringStream* stream) { 2965 void HGoto::PrintDataTo(StringStream* stream) {
2933 stream->Add("B%d", SuccessorAt(0)->block_id()); 2966 stream->Add("B%d", SuccessorAt(0)->block_id());
2934 } 2967 }
2935 2968
2936 2969
2937 void HCompareNumericAndBranch::InferRepresentation( 2970 void HCompareNumericAndBranch::InferRepresentation(
2938 HInferRepresentationPhase* h_infer) { 2971 HInferRepresentationPhase* h_infer) {
2939 Representation left_rep = left()->representation(); 2972 Representation left_rep = left()->representation();
2940 Representation right_rep = right()->representation(); 2973 Representation right_rep = right()->representation();
2941 Representation observed_left = observed_input_representation(0); 2974 Representation observed_left = observed_input_representation(0);
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
3977 if ((right_val == 0) && (left_val < 0)) { 4010 if ((right_val == 0) && (left_val < 0)) {
3978 return H_CONSTANT_DOUBLE(static_cast<uint32_t>(left_val)); 4011 return H_CONSTANT_DOUBLE(static_cast<uint32_t>(left_val));
3979 } 4012 }
3980 return H_CONSTANT_INT(static_cast<uint32_t>(left_val) >> right_val); 4013 return H_CONSTANT_INT(static_cast<uint32_t>(left_val) >> right_val);
3981 } 4014 }
3982 } 4015 }
3983 return new(zone) HShr(context, left, right); 4016 return new(zone) HShr(context, left, right);
3984 } 4017 }
3985 4018
3986 4019
4020 HInstruction* HSeqStringGetChar::New(Zone* zone,
4021 HValue* context,
4022 String::Encoding encoding,
4023 HValue* string,
4024 HValue* index) {
4025 if (FLAG_fold_constants && string->IsConstant() && index->IsConstant()) {
4026 HConstant* c_string = HConstant::cast(string);
4027 HConstant* c_index = HConstant::cast(index);
4028 if (c_string->HasStringValue() && c_index->HasInteger32Value()) {
4029 Handle<String> s = c_string->StringValue();
4030 int32_t i = c_index->Integer32Value();
4031 ASSERT_LE(0, i);
4032 ASSERT_LT(i, s->length());
4033 return H_CONSTANT_INT(s->Get(i));
4034 }
4035 }
4036 return new(zone) HSeqStringGetChar(encoding, string, index);
4037 }
4038
4039
3987 #undef H_CONSTANT_INT 4040 #undef H_CONSTANT_INT
3988 #undef H_CONSTANT_DOUBLE 4041 #undef H_CONSTANT_DOUBLE
3989 4042
3990 4043
3991 void HBitwise::PrintDataTo(StringStream* stream) { 4044 void HBitwise::PrintDataTo(StringStream* stream) {
3992 stream->Add(Token::Name(op_)); 4045 stream->Add(Token::Name(op_));
3993 stream->Add(" "); 4046 stream->Add(" ");
3994 HBitwiseBinaryOperation::PrintDataTo(stream); 4047 HBitwiseBinaryOperation::PrintDataTo(stream);
3995 } 4048 }
3996 4049
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
4291 break; 4344 break;
4292 case kExternalMemory: 4345 case kExternalMemory:
4293 stream->Add("[external-memory]"); 4346 stream->Add("[external-memory]");
4294 break; 4347 break;
4295 } 4348 }
4296 4349
4297 stream->Add("@%d", offset()); 4350 stream->Add("@%d", offset());
4298 } 4351 }
4299 4352
4300 } } // namespace v8::internal 4353 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/hydrogen-load-elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698