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

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

Issue 59023003: Generate TypedArrayInitialize builtin in hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Better implementation of HAdd::New 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/ia32/lithium-codegen-ia32.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 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 } 1262 }
1263 // Optimize double negation, a common pattern used for ToInt32(x). 1263 // Optimize double negation, a common pattern used for ToInt32(x).
1264 HValue* arg; 1264 HValue* arg;
1265 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) { 1265 if (MatchDoubleNegation(this, &arg) && !arg->CheckFlag(kUint32)) {
1266 return arg; 1266 return arg;
1267 } 1267 }
1268 return this; 1268 return this;
1269 } 1269 }
1270 1270
1271 1271
1272 Representation HAdd::RepresentationFromInputs() {
1273 Representation left_rep = left()->representation();
1274 if (left_rep.IsExternal()) {
1275 return Representation::External();
1276 }
1277 return HArithmeticBinaryOperation::RepresentationFromInputs();
1278 }
1279
1280
1281 Representation HAdd::RequiredInputRepresentation(int index) {
1282 if (index == 2) {
1283 Representation left_rep = left()->representation();
1284 if (left_rep.IsExternal()) {
1285 return Representation::Integer32();
1286 }
1287 }
1288 return HArithmeticBinaryOperation::RequiredInputRepresentation(index);
1289 }
1290
1291
1272 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { 1292 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
1273 return arg1->representation().IsSpecialization() && 1293 return arg1->representation().IsSpecialization() &&
1274 arg2->EqualsInteger32Constant(identity); 1294 arg2->EqualsInteger32Constant(identity);
1275 } 1295 }
1276 1296
1277 1297
1278 HValue* HAdd::Canonicalize() { 1298 HValue* HAdd::Canonicalize() {
1279 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0 1299 // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0
1280 if (IsIdentityOperation(left(), right(), 0) && 1300 if (IsIdentityOperation(left(), right(), 0) &&
1281 !left()->representation().IsDouble()) { // Left could be -0. 1301 !left()->representation().IsDouble()) { // Left could be -0.
(...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after
3749 if (TypeInfo::IsInt32Double(double_res)) { \ 3769 if (TypeInfo::IsInt32Double(double_res)) { \
3750 return H_CONSTANT_INT(double_res); \ 3770 return H_CONSTANT_INT(double_res); \
3751 } \ 3771 } \
3752 return H_CONSTANT_DOUBLE(double_res); \ 3772 return H_CONSTANT_DOUBLE(double_res); \
3753 } \ 3773 } \
3754 } \ 3774 } \
3755 return new(zone) HInstr(context, left, right); \ 3775 return new(zone) HInstr(context, left, right); \
3756 } 3776 }
3757 3777
3758 3778
3759 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +)
3760 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) 3779 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *)
3761 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) 3780 DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -)
3762 3781
3763 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR 3782 #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR
3764 3783
3765 3784
3785 HInstruction* HAdd::New(
3786 Zone* zone, HValue* context, HValue* left, HValue* right,
3787 Representation forced_representation) {
3788 if (!forced_representation.IsNone()) {
Dmitry Lomov (no reviews) 2013/11/19 09:42:04 I am not entirely convinced this is a good change.
danno 2013/11/20 09:45:25 I see your point, but I also really don't like the
3789 HAdd* result = new(zone) HAdd(context, left, right);
3790
3791 result->set_observed_input_representation(1, forced_representation);
3792 result->initialize_output_representation(forced_representation);
3793 return result;
3794 }
3795 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
3796 HConstant* c_left = HConstant::cast(left);
3797 HConstant* c_right = HConstant::cast(right);
3798 if ((c_left->HasNumberValue() && c_right->HasNumberValue())) {
3799 double double_res = c_left->DoubleValue() + c_right->DoubleValue();
3800 if (TypeInfo::IsInt32Double(double_res)) {
3801 return H_CONSTANT_INT(double_res);
3802 }
3803 return H_CONSTANT_DOUBLE(double_res);
3804 }
3805 }
3806 return new(zone) HAdd(context, left, right);
3807 }
3808
3809
3766 HInstruction* HStringAdd::New(Zone* zone, 3810 HInstruction* HStringAdd::New(Zone* zone,
3767 HValue* context, 3811 HValue* context,
3768 HValue* left, 3812 HValue* left,
3769 HValue* right, 3813 HValue* right,
3770 StringAddFlags flags) { 3814 StringAddFlags flags) {
3771 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { 3815 if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) {
3772 HConstant* c_right = HConstant::cast(right); 3816 HConstant* c_right = HConstant::cast(right);
3773 HConstant* c_left = HConstant::cast(left); 3817 HConstant* c_left = HConstant::cast(left);
3774 if (c_left->HasStringValue() && c_right->HasStringValue()) { 3818 if (c_left->HasStringValue() && c_right->HasStringValue()) {
3775 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString( 3819 Handle<String> concat = zone->isolate()->factory()->NewFlatConcatString(
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 break; 4409 break;
4366 case kExternalMemory: 4410 case kExternalMemory:
4367 stream->Add("[external-memory]"); 4411 stream->Add("[external-memory]");
4368 break; 4412 break;
4369 } 4413 }
4370 4414
4371 stream->Add("@%d", offset()); 4415 stream->Add("@%d", offset());
4372 } 4416 }
4373 4417
4374 } } // namespace v8::internal 4418 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698