OLD | NEW |
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 3032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 ? left()->range()->Copy(zone) | 3043 ? left()->range()->Copy(zone) |
3044 : new(zone) Range(); | 3044 : new(zone) Range(); |
3045 result->Shl(c->Integer32Value()); | 3045 result->Shl(c->Integer32Value()); |
3046 return result; | 3046 return result; |
3047 } | 3047 } |
3048 } | 3048 } |
3049 return HValue::InferRange(zone); | 3049 return HValue::InferRange(zone); |
3050 } | 3050 } |
3051 | 3051 |
3052 | 3052 |
| 3053 Range* HLoadNamedField::InferRange(Zone* zone) { |
| 3054 if (access().IsStringLength()) { |
| 3055 return new(zone) Range(0, String::kMaxLength); |
| 3056 } |
| 3057 return HValue::InferRange(zone); |
| 3058 } |
| 3059 |
| 3060 |
3053 Range* HLoadKeyed::InferRange(Zone* zone) { | 3061 Range* HLoadKeyed::InferRange(Zone* zone) { |
3054 switch (elements_kind()) { | 3062 switch (elements_kind()) { |
3055 case EXTERNAL_PIXEL_ELEMENTS: | 3063 case EXTERNAL_PIXEL_ELEMENTS: |
3056 return new(zone) Range(0, 255); | 3064 return new(zone) Range(0, 255); |
3057 case EXTERNAL_BYTE_ELEMENTS: | 3065 case EXTERNAL_BYTE_ELEMENTS: |
3058 return new(zone) Range(-128, 127); | 3066 return new(zone) Range(-128, 127); |
3059 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 3067 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
3060 return new(zone) Range(0, 255); | 3068 return new(zone) Range(0, 255); |
3061 case EXTERNAL_SHORT_ELEMENTS: | 3069 case EXTERNAL_SHORT_ELEMENTS: |
3062 return new(zone) Range(-32768, 32767); | 3070 return new(zone) Range(-32768, 32767); |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 return HConstant::New(zone, context, | 3932 return HConstant::New(zone, context, |
3925 LookupSingleCharacterStringFromCode(isolate, code)); | 3933 LookupSingleCharacterStringFromCode(isolate, code)); |
3926 } | 3934 } |
3927 return HConstant::New(zone, context, isolate->factory()->empty_string()); | 3935 return HConstant::New(zone, context, isolate->factory()->empty_string()); |
3928 } | 3936 } |
3929 } | 3937 } |
3930 return new(zone) HStringCharFromCode(context, char_code); | 3938 return new(zone) HStringCharFromCode(context, char_code); |
3931 } | 3939 } |
3932 | 3940 |
3933 | 3941 |
3934 HInstruction* HStringLength::New(Zone* zone, HValue* context, HValue* string) { | |
3935 if (FLAG_fold_constants && string->IsConstant()) { | |
3936 HConstant* c_string = HConstant::cast(string); | |
3937 if (c_string->HasStringValue()) { | |
3938 return HConstant::New(zone, context, c_string->StringValue()->length()); | |
3939 } | |
3940 } | |
3941 return new(zone) HStringLength(string); | |
3942 } | |
3943 | |
3944 | |
3945 HInstruction* HUnaryMathOperation::New( | 3942 HInstruction* HUnaryMathOperation::New( |
3946 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { | 3943 Zone* zone, HValue* context, HValue* value, BuiltinFunctionId op) { |
3947 do { | 3944 do { |
3948 if (!FLAG_fold_constants) break; | 3945 if (!FLAG_fold_constants) break; |
3949 if (!value->IsConstant()) break; | 3946 if (!value->IsConstant()) break; |
3950 HConstant* constant = HConstant::cast(value); | 3947 HConstant* constant = HConstant::cast(value); |
3951 if (!constant->HasNumberValue()) break; | 3948 if (!constant->HasNumberValue()) break; |
3952 double d = constant->DoubleValue(); | 3949 double d = constant->DoubleValue(); |
3953 if (std::isnan(d)) { // NaN poisons everything. | 3950 if (std::isnan(d)) { // NaN poisons everything. |
3954 return H_CONSTANT_DOUBLE(OS::nan_value()); | 3951 return H_CONSTANT_DOUBLE(OS::nan_value()); |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4412 // try to GVN loads, but don't hoist above map changes | 4409 // try to GVN loads, but don't hoist above map changes |
4413 instr->SetFlag(HValue::kUseGVN); | 4410 instr->SetFlag(HValue::kUseGVN); |
4414 instr->SetGVNFlag(kDependsOnMaps); | 4411 instr->SetGVNFlag(kDependsOnMaps); |
4415 } | 4412 } |
4416 | 4413 |
4417 switch (portion()) { | 4414 switch (portion()) { |
4418 case kArrayLengths: | 4415 case kArrayLengths: |
4419 instr->SetGVNFlag(is_store | 4416 instr->SetGVNFlag(is_store |
4420 ? kChangesArrayLengths : kDependsOnArrayLengths); | 4417 ? kChangesArrayLengths : kDependsOnArrayLengths); |
4421 break; | 4418 break; |
| 4419 case kStringLengths: |
| 4420 instr->SetGVNFlag(is_store |
| 4421 ? kChangesStringLengths : kDependsOnStringLengths); |
| 4422 break; |
4422 case kInobject: | 4423 case kInobject: |
4423 instr->SetGVNFlag(is_store | 4424 instr->SetGVNFlag(is_store |
4424 ? kChangesInobjectFields : kDependsOnInobjectFields); | 4425 ? kChangesInobjectFields : kDependsOnInobjectFields); |
4425 break; | 4426 break; |
4426 case kDouble: | 4427 case kDouble: |
4427 instr->SetGVNFlag(is_store | 4428 instr->SetGVNFlag(is_store |
4428 ? kChangesDoubleFields : kDependsOnDoubleFields); | 4429 ? kChangesDoubleFields : kDependsOnDoubleFields); |
4429 break; | 4430 break; |
4430 case kBackingStore: | 4431 case kBackingStore: |
4431 instr->SetGVNFlag(is_store | 4432 instr->SetGVNFlag(is_store |
(...skipping 13 matching lines...) Expand all Loading... |
4445 break; | 4446 break; |
4446 } | 4447 } |
4447 } | 4448 } |
4448 | 4449 |
4449 | 4450 |
4450 void HObjectAccess::PrintTo(StringStream* stream) { | 4451 void HObjectAccess::PrintTo(StringStream* stream) { |
4451 stream->Add("."); | 4452 stream->Add("."); |
4452 | 4453 |
4453 switch (portion()) { | 4454 switch (portion()) { |
4454 case kArrayLengths: | 4455 case kArrayLengths: |
| 4456 case kStringLengths: |
4455 stream->Add("%length"); | 4457 stream->Add("%length"); |
4456 break; | 4458 break; |
4457 case kElementsPointer: | 4459 case kElementsPointer: |
4458 stream->Add("%elements"); | 4460 stream->Add("%elements"); |
4459 break; | 4461 break; |
4460 case kMaps: | 4462 case kMaps: |
4461 stream->Add("%map"); | 4463 stream->Add("%map"); |
4462 break; | 4464 break; |
4463 case kDouble: // fall through | 4465 case kDouble: // fall through |
4464 case kInobject: | 4466 case kInobject: |
4465 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4467 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
4466 stream->Add("[in-object]"); | 4468 stream->Add("[in-object]"); |
4467 break; | 4469 break; |
4468 case kBackingStore: | 4470 case kBackingStore: |
4469 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4471 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
4470 stream->Add("[backing-store]"); | 4472 stream->Add("[backing-store]"); |
4471 break; | 4473 break; |
4472 case kExternalMemory: | 4474 case kExternalMemory: |
4473 stream->Add("[external-memory]"); | 4475 stream->Add("[external-memory]"); |
4474 break; | 4476 break; |
4475 } | 4477 } |
4476 | 4478 |
4477 stream->Add("@%d", offset()); | 4479 stream->Add("@%d", offset()); |
4478 } | 4480 } |
4479 | 4481 |
4480 } } // namespace v8::internal | 4482 } } // namespace v8::internal |
OLD | NEW |