OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 if (state.op() == Token::ADD && | 1354 if (state.op() == Token::ADD && |
1355 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && | 1355 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && |
1356 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { | 1356 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { |
1357 // For the generic add stub a fast case for string addition is performance | 1357 // For the generic add stub a fast case for string addition is performance |
1358 // critical. | 1358 // critical. |
1359 if (left_type->Maybe(Type::String())) { | 1359 if (left_type->Maybe(Type::String())) { |
1360 IfBuilder if_leftisstring(this); | 1360 IfBuilder if_leftisstring(this); |
1361 if_leftisstring.If<HIsStringAndBranch>(left); | 1361 if_leftisstring.If<HIsStringAndBranch>(left); |
1362 if_leftisstring.Then(); | 1362 if_leftisstring.Then(); |
1363 { | 1363 { |
1364 Push(BuildBinaryOperation( | 1364 Push(BuildBinaryOperation(state.op(), left, right, Type::String(zone()), |
1365 state.op(), left, right, | 1365 right_type, result_type, |
1366 Type::String(zone()), right_type, | 1366 state.fixed_right_arg(), allocation_mode, |
1367 result_type, state.fixed_right_arg(), | 1367 state.strength())); |
1368 allocation_mode, state.language_mode())); | |
1369 } | 1368 } |
1370 if_leftisstring.Else(); | 1369 if_leftisstring.Else(); |
1371 { | 1370 { |
1372 Push(BuildBinaryOperation( | 1371 Push(BuildBinaryOperation( |
1373 state.op(), left, right, | 1372 state.op(), left, right, left_type, right_type, result_type, |
1374 left_type, right_type, result_type, | 1373 state.fixed_right_arg(), allocation_mode, state.strength())); |
1375 state.fixed_right_arg(), allocation_mode, | |
1376 state.language_mode())); | |
1377 } | 1374 } |
1378 if_leftisstring.End(); | 1375 if_leftisstring.End(); |
1379 result = Pop(); | 1376 result = Pop(); |
1380 } else { | 1377 } else { |
1381 IfBuilder if_rightisstring(this); | 1378 IfBuilder if_rightisstring(this); |
1382 if_rightisstring.If<HIsStringAndBranch>(right); | 1379 if_rightisstring.If<HIsStringAndBranch>(right); |
1383 if_rightisstring.Then(); | 1380 if_rightisstring.Then(); |
1384 { | 1381 { |
1385 Push(BuildBinaryOperation( | 1382 Push(BuildBinaryOperation(state.op(), left, right, left_type, |
1386 state.op(), left, right, | 1383 Type::String(zone()), result_type, |
1387 left_type, Type::String(zone()), | 1384 state.fixed_right_arg(), allocation_mode, |
1388 result_type, state.fixed_right_arg(), | 1385 state.strength())); |
1389 allocation_mode, state.language_mode())); | |
1390 } | 1386 } |
1391 if_rightisstring.Else(); | 1387 if_rightisstring.Else(); |
1392 { | 1388 { |
1393 Push(BuildBinaryOperation( | 1389 Push(BuildBinaryOperation( |
1394 state.op(), left, right, | 1390 state.op(), left, right, left_type, right_type, result_type, |
1395 left_type, right_type, result_type, | 1391 state.fixed_right_arg(), allocation_mode, state.strength())); |
1396 state.fixed_right_arg(), allocation_mode, | |
1397 state.language_mode())); | |
1398 } | 1392 } |
1399 if_rightisstring.End(); | 1393 if_rightisstring.End(); |
1400 result = Pop(); | 1394 result = Pop(); |
1401 } | 1395 } |
1402 } else { | 1396 } else { |
1403 result = BuildBinaryOperation( | 1397 result = BuildBinaryOperation( |
1404 state.op(), left, right, | 1398 state.op(), left, right, left_type, right_type, result_type, |
1405 left_type, right_type, result_type, | 1399 state.fixed_right_arg(), allocation_mode, state.strength()); |
1406 state.fixed_right_arg(), allocation_mode, state.language_mode()); | |
1407 } | 1400 } |
1408 | 1401 |
1409 // If we encounter a generic argument, the number conversion is | 1402 // If we encounter a generic argument, the number conversion is |
1410 // observable, thus we cannot afford to bail out after the fact. | 1403 // observable, thus we cannot afford to bail out after the fact. |
1411 if (!state.HasSideEffects()) { | 1404 if (!state.HasSideEffects()) { |
1412 result = EnforceNumberType(result, result_type); | 1405 result = EnforceNumberType(result, result_type); |
1413 } | 1406 } |
1414 | 1407 |
1415 return result; | 1408 return result; |
1416 } | 1409 } |
(...skipping 11 matching lines...) Expand all Loading... |
1428 HValue* allocation_site = GetParameter( | 1421 HValue* allocation_site = GetParameter( |
1429 BinaryOpWithAllocationSiteStub::kAllocationSite); | 1422 BinaryOpWithAllocationSiteStub::kAllocationSite); |
1430 HValue* left = GetParameter(BinaryOpWithAllocationSiteStub::kLeft); | 1423 HValue* left = GetParameter(BinaryOpWithAllocationSiteStub::kLeft); |
1431 HValue* right = GetParameter(BinaryOpWithAllocationSiteStub::kRight); | 1424 HValue* right = GetParameter(BinaryOpWithAllocationSiteStub::kRight); |
1432 | 1425 |
1433 Type* left_type = state.GetLeftType(zone()); | 1426 Type* left_type = state.GetLeftType(zone()); |
1434 Type* right_type = state.GetRightType(zone()); | 1427 Type* right_type = state.GetRightType(zone()); |
1435 Type* result_type = state.GetResultType(zone()); | 1428 Type* result_type = state.GetResultType(zone()); |
1436 HAllocationMode allocation_mode(allocation_site); | 1429 HAllocationMode allocation_mode(allocation_site); |
1437 | 1430 |
1438 return BuildBinaryOperation(state.op(), left, right, | 1431 return BuildBinaryOperation(state.op(), left, right, left_type, right_type, |
1439 left_type, right_type, result_type, | 1432 result_type, state.fixed_right_arg(), |
1440 state.fixed_right_arg(), allocation_mode, | 1433 allocation_mode, state.strength()); |
1441 state.language_mode()); | |
1442 } | 1434 } |
1443 | 1435 |
1444 | 1436 |
1445 Handle<Code> BinaryOpWithAllocationSiteStub::GenerateCode() { | 1437 Handle<Code> BinaryOpWithAllocationSiteStub::GenerateCode() { |
1446 return DoGenerateCode(this); | 1438 return DoGenerateCode(this); |
1447 } | 1439 } |
1448 | 1440 |
1449 | 1441 |
1450 template <> | 1442 template <> |
1451 HValue* CodeStubGraphBuilder<StringAddStub>::BuildCodeInitializedStub() { | 1443 HValue* CodeStubGraphBuilder<StringAddStub>::BuildCodeInitializedStub() { |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 return Pop(); | 2229 return Pop(); |
2238 } | 2230 } |
2239 | 2231 |
2240 | 2232 |
2241 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2233 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2242 return DoGenerateCode(this); | 2234 return DoGenerateCode(this); |
2243 } | 2235 } |
2244 | 2236 |
2245 } // namespace internal | 2237 } // namespace internal |
2246 } // namespace v8 | 2238 } // namespace v8 |
OLD | NEW |