| 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 23 matching lines...) Expand all Loading... |
| 34 #include "factory.h" | 34 #include "factory.h" |
| 35 #include "gdb-jit.h" | 35 #include "gdb-jit.h" |
| 36 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 | 41 |
| 42 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() | 42 CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() |
| 43 : register_param_count_(-1), | 43 : register_param_count_(-1), |
| 44 stack_parameter_count_(NULL), | 44 stack_parameter_count_(no_reg), |
| 45 hint_stack_parameter_count_(-1), | 45 hint_stack_parameter_count_(-1), |
| 46 function_mode_(NOT_JS_FUNCTION_STUB_MODE), | 46 function_mode_(NOT_JS_FUNCTION_STUB_MODE), |
| 47 register_params_(NULL), | 47 register_params_(NULL), |
| 48 deoptimization_handler_(NULL), | 48 deoptimization_handler_(NULL), |
| 49 miss_handler_(), | 49 miss_handler_(), |
| 50 has_miss_handler_(false) { } | 50 has_miss_handler_(false) { } |
| 51 | 51 |
| 52 | 52 |
| 53 bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) { | 53 bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) { |
| 54 UnseededNumberDictionary* stubs = isolate->heap()->code_stubs(); | 54 UnseededNumberDictionary* stubs = isolate->heap()->code_stubs(); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_LEFT, isolate); | 466 Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_LEFT, isolate); |
| 467 Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_RIGHT, isolate); | 467 Generate(Token::SHL, SMI, SMI, INT32, OVERWRITE_RIGHT, isolate); |
| 468 Generate(Token::SHL, SMI, SMI, SMI, NO_OVERWRITE, isolate); | 468 Generate(Token::SHL, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
| 469 Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); | 469 Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
| 470 Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); | 470 Generate(Token::SHL, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
| 471 Generate(Token::SHR, INT32, SMI, SMI, NO_OVERWRITE, isolate); | 471 Generate(Token::SHR, INT32, SMI, SMI, NO_OVERWRITE, isolate); |
| 472 Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_LEFT, isolate); | 472 Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_LEFT, isolate); |
| 473 Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); | 473 Generate(Token::SHR, INT32, SMI, SMI, OVERWRITE_RIGHT, isolate); |
| 474 Generate(Token::SHR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); | 474 Generate(Token::SHR, NUMBER, SMI, SMI, NO_OVERWRITE, isolate); |
| 475 Generate(Token::SHR, NUMBER, SMI, SMI, OVERWRITE_LEFT, isolate); | 475 Generate(Token::SHR, NUMBER, SMI, SMI, OVERWRITE_LEFT, isolate); |
| 476 Generate(Token::SHR, NUMBER, SMI, INT32, OVERWRITE_RIGHT, isolate); |
| 476 Generate(Token::SHR, SMI, SMI, SMI, NO_OVERWRITE, isolate); | 477 Generate(Token::SHR, SMI, SMI, SMI, NO_OVERWRITE, isolate); |
| 477 Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); | 478 Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_LEFT, isolate); |
| 478 Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); | 479 Generate(Token::SHR, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate); |
| 479 Generate(Token::SUB, INT32, INT32, INT32, NO_OVERWRITE, isolate); | 480 Generate(Token::SUB, INT32, INT32, INT32, NO_OVERWRITE, isolate); |
| 480 Generate(Token::SUB, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); | 481 Generate(Token::SUB, INT32, INT32, INT32, OVERWRITE_LEFT, isolate); |
| 481 Generate(Token::SUB, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); | 482 Generate(Token::SUB, INT32, NUMBER, NUMBER, NO_OVERWRITE, isolate); |
| 482 Generate(Token::SUB, INT32, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); | 483 Generate(Token::SUB, INT32, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate); |
| 483 Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); | 484 Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_LEFT, isolate); |
| 484 Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); | 485 Generate(Token::SUB, INT32, SMI, INT32, OVERWRITE_RIGHT, isolate); |
| 485 Generate(Token::SUB, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); | 486 Generate(Token::SUB, NUMBER, INT32, NUMBER, NO_OVERWRITE, isolate); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 right->ToInt32(&value) && can_encode_arg_value(value) && | 563 right->ToInt32(&value) && can_encode_arg_value(value) && |
| 563 (left_state_ == SMI || left_state_ == INT32) && | 564 (left_state_ == SMI || left_state_ == INT32) && |
| 564 (result_state_ == NONE || !fixed_right_arg_.has_value); | 565 (result_state_ == NONE || !fixed_right_arg_.has_value); |
| 565 | 566 |
| 566 fixed_right_arg_ = Maybe<int32_t>(new_has_fixed_right_arg, value); | 567 fixed_right_arg_ = Maybe<int32_t>(new_has_fixed_right_arg, value); |
| 567 | 568 |
| 568 if (result.has_value) UpdateStatus(result.value, &result_state_); | 569 if (result.has_value) UpdateStatus(result.value, &result_state_); |
| 569 | 570 |
| 570 State max_input = Max(left_state_, right_state_); | 571 State max_input = Max(left_state_, right_state_); |
| 571 | 572 |
| 572 // Avoid unnecessary Representation changes. | 573 if (!has_int_result() && op_ != Token::SHR && |
| 573 if (left_state_ == STRING && right_state_ < STRING) { | 574 max_input <= NUMBER && max_input > result_state_) { |
| 574 right_state_ = GENERIC; | |
| 575 } else if (right_state_ == STRING && left_state_ < STRING) { | |
| 576 left_state_ = GENERIC; | |
| 577 } else if ((right_state_ == GENERIC && left_state_ != STRING) || | |
| 578 (left_state_ == GENERIC && right_state_ != STRING)) { | |
| 579 left_state_ = right_state_ = GENERIC; | |
| 580 } else if (!has_int_result() && op_ != Token::SHR && | |
| 581 max_input <= NUMBER && max_input > result_state_) { | |
| 582 result_state_ = max_input; | 575 result_state_ = max_input; |
| 583 } | 576 } |
| 584 | 577 |
| 585 ASSERT(result_state_ <= (has_int_result() ? INT32 : NUMBER) || | 578 ASSERT(result_state_ <= (has_int_result() ? INT32 : NUMBER) || |
| 586 op_ == Token::ADD); | 579 op_ == Token::ADD); |
| 587 | 580 |
| 588 if (old_state == GetExtraICState()) { | 581 if (old_state == GetExtraICState()) { |
| 589 // Since the fpu is to precise, we might bail out on numbers which | 582 // Tagged operations can lead to non-truncating HChanges |
| 590 // actually would truncate with 64 bit precision. | 583 if (left->IsUndefined() || left->IsBoolean()) { |
| 591 ASSERT(!CpuFeatures::IsSupported(SSE2) && | 584 left_state_ = GENERIC; |
| 592 result_state_ <= INT32); | 585 } else if (right->IsUndefined() || right->IsBoolean()) { |
| 593 result_state_ = NUMBER; | 586 right_state_ = GENERIC; |
| 587 } else { |
| 588 // Since the fpu is to precise, we might bail out on numbers which |
| 589 // actually would truncate with 64 bit precision. |
| 590 ASSERT(!CpuFeatures::IsSupported(SSE2) && |
| 591 result_state_ <= INT32); |
| 592 result_state_ = NUMBER; |
| 593 } |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 | 597 |
| 598 void BinaryOpStub::UpdateStatus(Handle<Object> object, | 598 void BinaryOpStub::UpdateStatus(Handle<Object> object, |
| 599 State* state) { | 599 State* state) { |
| 600 bool is_truncating = (op_ == Token::BIT_AND || op_ == Token::BIT_OR || |
| 601 op_ == Token::BIT_XOR || op_ == Token::SAR || |
| 602 op_ == Token::SHL || op_ == Token::SHR); |
| 600 v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(object); | 603 v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(object); |
| 604 if (object->IsBoolean() && is_truncating) { |
| 605 // Booleans are converted by truncating by HChange. |
| 606 type = TypeInfo::Integer32(); |
| 607 } |
| 601 if (object->IsUndefined()) { | 608 if (object->IsUndefined()) { |
| 602 // Undefined will be automatically truncated for us by HChange. | 609 // Undefined will be automatically truncated for us by HChange. |
| 603 type = (op_ == Token::BIT_AND || op_ == Token::BIT_OR || | 610 type = is_truncating ? TypeInfo::Integer32() : TypeInfo::Double(); |
| 604 op_ == Token::BIT_XOR || op_ == Token::SAR || | |
| 605 op_ == Token::SHL || op_ == Token::SHR) | |
| 606 ? TypeInfo::Integer32() | |
| 607 : TypeInfo::Double(); | |
| 608 } | 611 } |
| 609 State int_state = SmiValuesAre32Bits() ? NUMBER : INT32; | 612 State int_state = SmiValuesAre32Bits() ? NUMBER : INT32; |
| 610 State new_state = NONE; | 613 State new_state = NONE; |
| 611 if (type.IsSmi()) { | 614 if (type.IsSmi()) { |
| 612 new_state = SMI; | 615 new_state = SMI; |
| 613 } else if (type.IsInteger32()) { | 616 } else if (type.IsInteger32()) { |
| 614 new_state = int_state; | 617 new_state = int_state; |
| 615 } else if (type.IsNumber()) { | 618 } else if (type.IsNumber()) { |
| 616 new_state = NUMBER; | 619 new_state = NUMBER; |
| 617 } else if (object->IsString() && operation() == Token::ADD) { | 620 } else if (object->IsString() && operation() == Token::ADD) { |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 void ArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) { | 1114 void ArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) { |
| 1112 ArrayNoArgumentConstructorStub stub1(GetInitialFastElementsKind()); | 1115 ArrayNoArgumentConstructorStub stub1(GetInitialFastElementsKind()); |
| 1113 InstallDescriptor(isolate, &stub1); | 1116 InstallDescriptor(isolate, &stub1); |
| 1114 ArraySingleArgumentConstructorStub stub2(GetInitialFastElementsKind()); | 1117 ArraySingleArgumentConstructorStub stub2(GetInitialFastElementsKind()); |
| 1115 InstallDescriptor(isolate, &stub2); | 1118 InstallDescriptor(isolate, &stub2); |
| 1116 ArrayNArgumentsConstructorStub stub3(GetInitialFastElementsKind()); | 1119 ArrayNArgumentsConstructorStub stub3(GetInitialFastElementsKind()); |
| 1117 InstallDescriptor(isolate, &stub3); | 1120 InstallDescriptor(isolate, &stub3); |
| 1118 } | 1121 } |
| 1119 | 1122 |
| 1120 | 1123 |
| 1124 void NumberToStringStub::InstallDescriptors(Isolate* isolate) { |
| 1125 NumberToStringStub stub; |
| 1126 InstallDescriptor(isolate, &stub); |
| 1127 } |
| 1128 |
| 1129 |
| 1121 void FastNewClosureStub::InstallDescriptors(Isolate* isolate) { | 1130 void FastNewClosureStub::InstallDescriptors(Isolate* isolate) { |
| 1122 FastNewClosureStub stub(STRICT_MODE, false); | 1131 FastNewClosureStub stub(STRICT_MODE, false); |
| 1123 InstallDescriptor(isolate, &stub); | 1132 InstallDescriptor(isolate, &stub); |
| 1124 } | 1133 } |
| 1125 | 1134 |
| 1126 | 1135 |
| 1127 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) | 1136 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
| 1128 : argument_count_(ANY) { | 1137 : argument_count_(ANY) { |
| 1129 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 1138 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 1130 } | 1139 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1154 InstallDescriptor(isolate, &stub3); | 1163 InstallDescriptor(isolate, &stub3); |
| 1155 } | 1164 } |
| 1156 | 1165 |
| 1157 InternalArrayConstructorStub::InternalArrayConstructorStub( | 1166 InternalArrayConstructorStub::InternalArrayConstructorStub( |
| 1158 Isolate* isolate) { | 1167 Isolate* isolate) { |
| 1159 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); | 1168 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); |
| 1160 } | 1169 } |
| 1161 | 1170 |
| 1162 | 1171 |
| 1163 } } // namespace v8::internal | 1172 } } // namespace v8::internal |
| OLD | NEW |