| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 __ dd(length); | 379 __ dd(length); |
| 380 for (unsigned i = 0; i < length; ++i) { | 380 for (unsigned i = 0; i < length; ++i) { |
| 381 __ dd(back_edges_[i].id.ToInt()); | 381 __ dd(back_edges_[i].id.ToInt()); |
| 382 __ dd(back_edges_[i].pc); | 382 __ dd(back_edges_[i].pc); |
| 383 __ dd(back_edges_[i].loop_depth); | 383 __ dd(back_edges_[i].loop_depth); |
| 384 } | 384 } |
| 385 return offset; | 385 return offset; |
| 386 } | 386 } |
| 387 | 387 |
| 388 | 388 |
| 389 void FullCodeGenerator::InitializeFeedbackVector() { | |
| 390 int length = info_->function()->slot_count(); | |
| 391 ASSERT_EQ(isolate()->heap()->the_hole_value(), | |
| 392 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | |
| 393 feedback_vector_ = isolate()->factory()->NewFixedArrayWithHoles(length, | |
| 394 TENURED); | |
| 395 } | |
| 396 | |
| 397 | |
| 398 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) { | 389 void FullCodeGenerator::PopulateDeoptimizationData(Handle<Code> code) { |
| 399 // Fill in the deoptimization information. | 390 // Fill in the deoptimization information. |
| 400 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty()); | 391 ASSERT(info_->HasDeoptimizationSupport() || bailout_entries_.is_empty()); |
| 401 if (!info_->HasDeoptimizationSupport()) return; | 392 if (!info_->HasDeoptimizationSupport()) return; |
| 402 int length = bailout_entries_.length(); | 393 int length = bailout_entries_.length(); |
| 403 Handle<DeoptimizationOutputData> data = isolate()->factory()-> | 394 Handle<DeoptimizationOutputData> data = isolate()->factory()-> |
| 404 NewDeoptimizationOutputData(length, TENURED); | 395 NewDeoptimizationOutputData(length, TENURED); |
| 405 for (int i = 0; i < length; i++) { | 396 for (int i = 0; i < length; i++) { |
| 406 data->SetAstId(i, bailout_entries_[i].id); | 397 data->SetAstId(i, bailout_entries_[i].id); |
| 407 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state)); | 398 data->SetPcAndState(i, Smi::FromInt(bailout_entries_[i].pc_and_state)); |
| 408 } | 399 } |
| 409 code->set_deoptimization_data(*data); | 400 code->set_deoptimization_data(*data); |
| 410 } | 401 } |
| 411 | 402 |
| 412 | 403 |
| 413 void FullCodeGenerator::PopulateTypeFeedbackInfo(Handle<Code> code) { | 404 void FullCodeGenerator::PopulateTypeFeedbackInfo(Handle<Code> code) { |
| 414 Handle<TypeFeedbackInfo> info = isolate()->factory()->NewTypeFeedbackInfo(); | 405 Handle<TypeFeedbackInfo> info = isolate()->factory()->NewTypeFeedbackInfo(); |
| 415 info->set_ic_total_count(ic_total_count_); | 406 info->set_ic_total_count(ic_total_count_); |
| 416 info->set_feedback_vector(*FeedbackVector()); | |
| 417 ASSERT(!isolate()->heap()->InNewSpace(*info)); | 407 ASSERT(!isolate()->heap()->InNewSpace(*info)); |
| 418 code->set_type_feedback_info(*info); | 408 code->set_type_feedback_info(*info); |
| 419 } | 409 } |
| 420 | 410 |
| 421 | 411 |
| 422 void FullCodeGenerator::Initialize() { | 412 void FullCodeGenerator::Initialize() { |
| 423 // The generation of debug code must match between the snapshot code and the | 413 // The generation of debug code must match between the snapshot code and the |
| 424 // code that is generated later. This is assumed by the debugger when it is | 414 // code that is generated later. This is assumed by the debugger when it is |
| 425 // calculating PC offsets after generating a debug version of code. Therefore | 415 // calculating PC offsets after generating a debug version of code. Therefore |
| 426 // we disable the production of debug code in the full compiler if we are | 416 // we disable the production of debug code in the full compiler if we are |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 interface->Allocate(scope->module_var()->index()); | 795 interface->Allocate(scope->module_var()->index()); |
| 806 int index = module_index_++; | 796 int index = module_index_++; |
| 807 | 797 |
| 808 Handle<ModuleInfo> description = | 798 Handle<ModuleInfo> description = |
| 809 ModuleInfo::Create(isolate(), interface, scope_); | 799 ModuleInfo::Create(isolate(), interface, scope_); |
| 810 modules_->set(index, *description); | 800 modules_->set(index, *description); |
| 811 } | 801 } |
| 812 | 802 |
| 813 | 803 |
| 814 int FullCodeGenerator::DeclareGlobalsFlags() { | 804 int FullCodeGenerator::DeclareGlobalsFlags() { |
| 815 ASSERT(DeclareGlobalsLanguageMode::is_valid(language_mode())); | 805 ASSERT(DeclareGlobalsStrictMode::is_valid(strict_mode())); |
| 816 return DeclareGlobalsEvalFlag::encode(is_eval()) | | 806 return DeclareGlobalsEvalFlag::encode(is_eval()) | |
| 817 DeclareGlobalsNativeFlag::encode(is_native()) | | 807 DeclareGlobalsNativeFlag::encode(is_native()) | |
| 818 DeclareGlobalsLanguageMode::encode(language_mode()); | 808 DeclareGlobalsStrictMode::encode(strict_mode()); |
| 819 } | 809 } |
| 820 | 810 |
| 821 | 811 |
| 822 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { | 812 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { |
| 823 CodeGenerator::RecordPositions(masm_, fun->start_position()); | 813 CodeGenerator::RecordPositions(masm_, fun->start_position()); |
| 824 } | 814 } |
| 825 | 815 |
| 826 | 816 |
| 827 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { | 817 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { |
| 828 CodeGenerator::RecordPositions(masm_, fun->end_position() - 1); | 818 CodeGenerator::RecordPositions(masm_, fun->end_position() - 1); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 | 888 |
| 899 | 889 |
| 900 // Lookup table for code generators for special runtime calls which are | 890 // Lookup table for code generators for special runtime calls which are |
| 901 // generated inline. | 891 // generated inline. |
| 902 #define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \ | 892 #define INLINE_FUNCTION_GENERATOR_ADDRESS(Name, argc, ressize) \ |
| 903 &FullCodeGenerator::Emit##Name, | 893 &FullCodeGenerator::Emit##Name, |
| 904 | 894 |
| 905 const FullCodeGenerator::InlineFunctionGenerator | 895 const FullCodeGenerator::InlineFunctionGenerator |
| 906 FullCodeGenerator::kInlineFunctionGenerators[] = { | 896 FullCodeGenerator::kInlineFunctionGenerators[] = { |
| 907 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | 897 INLINE_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) |
| 908 INLINE_RUNTIME_FUNCTION_LIST(INLINE_FUNCTION_GENERATOR_ADDRESS) | |
| 909 }; | 898 }; |
| 910 #undef INLINE_FUNCTION_GENERATOR_ADDRESS | 899 #undef INLINE_FUNCTION_GENERATOR_ADDRESS |
| 911 | 900 |
| 912 | 901 |
| 913 FullCodeGenerator::InlineFunctionGenerator | 902 FullCodeGenerator::InlineFunctionGenerator |
| 914 FullCodeGenerator::FindInlineFunctionGenerator(Runtime::FunctionId id) { | 903 FullCodeGenerator::FindInlineFunctionGenerator(Runtime::FunctionId id) { |
| 915 int lookup_index = | 904 int lookup_index = |
| 916 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction); | 905 static_cast<int>(id) - static_cast<int>(Runtime::kFirstInlineFunction); |
| 917 ASSERT(lookup_index >= 0); | 906 ASSERT(lookup_index >= 0); |
| 918 ASSERT(static_cast<size_t>(lookup_index) < | 907 ASSERT(static_cast<size_t>(lookup_index) < |
| (...skipping 24 matching lines...) Expand all Loading... |
| 943 ASSERT(args->length() == 2); | 932 ASSERT(args->length() == 2); |
| 944 EmitGeneratorResume(args->at(0), args->at(1), JSGeneratorObject::THROW); | 933 EmitGeneratorResume(args->at(0), args->at(1), JSGeneratorObject::THROW); |
| 945 } | 934 } |
| 946 | 935 |
| 947 | 936 |
| 948 void FullCodeGenerator::EmitDebugBreakInOptimizedCode(CallRuntime* expr) { | 937 void FullCodeGenerator::EmitDebugBreakInOptimizedCode(CallRuntime* expr) { |
| 949 context()->Plug(handle(Smi::FromInt(0), isolate())); | 938 context()->Plug(handle(Smi::FromInt(0), isolate())); |
| 950 } | 939 } |
| 951 | 940 |
| 952 | 941 |
| 942 void FullCodeGenerator::EmitDoubleHi(CallRuntime* expr) { |
| 943 ZoneList<Expression*>* args = expr->arguments(); |
| 944 ASSERT(args->length() == 1); |
| 945 VisitForStackValue(args->at(0)); |
| 946 masm()->CallRuntime(Runtime::kDoubleHi, 1); |
| 947 context()->Plug(result_register()); |
| 948 } |
| 949 |
| 950 |
| 951 void FullCodeGenerator::EmitDoubleLo(CallRuntime* expr) { |
| 952 ZoneList<Expression*>* args = expr->arguments(); |
| 953 ASSERT(args->length() == 1); |
| 954 VisitForStackValue(args->at(0)); |
| 955 masm()->CallRuntime(Runtime::kDoubleLo, 1); |
| 956 context()->Plug(result_register()); |
| 957 } |
| 958 |
| 959 |
| 960 void FullCodeGenerator::EmitConstructDouble(CallRuntime* expr) { |
| 961 ZoneList<Expression*>* args = expr->arguments(); |
| 962 ASSERT(args->length() == 2); |
| 963 VisitForStackValue(args->at(0)); |
| 964 VisitForStackValue(args->at(1)); |
| 965 masm()->CallRuntime(Runtime::kConstructDouble, 2); |
| 966 context()->Plug(result_register()); |
| 967 } |
| 968 |
| 969 |
| 953 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 970 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 954 switch (expr->op()) { | 971 switch (expr->op()) { |
| 955 case Token::COMMA: | 972 case Token::COMMA: |
| 956 return VisitComma(expr); | 973 return VisitComma(expr); |
| 957 case Token::OR: | 974 case Token::OR: |
| 958 case Token::AND: | 975 case Token::AND: |
| 959 return VisitLogicalExpression(expr); | 976 return VisitLogicalExpression(expr); |
| 960 default: | 977 default: |
| 961 return VisitArithmeticExpression(expr); | 978 return VisitArithmeticExpression(expr); |
| 962 } | 979 } |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 ASSERT(!fun_template.IsEmpty()); | 1598 ASSERT(!fun_template.IsEmpty()); |
| 1582 | 1599 |
| 1583 // Instantiate the function and create a shared function info from it. | 1600 // Instantiate the function and create a shared function info from it. |
| 1584 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); | 1601 Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction()); |
| 1585 const int literals = fun->NumberOfLiterals(); | 1602 const int literals = fun->NumberOfLiterals(); |
| 1586 Handle<Code> code = Handle<Code>(fun->shared()->code()); | 1603 Handle<Code> code = Handle<Code>(fun->shared()->code()); |
| 1587 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); | 1604 Handle<Code> construct_stub = Handle<Code>(fun->shared()->construct_stub()); |
| 1588 bool is_generator = false; | 1605 bool is_generator = false; |
| 1589 Handle<SharedFunctionInfo> shared = | 1606 Handle<SharedFunctionInfo> shared = |
| 1590 isolate()->factory()->NewSharedFunctionInfo(name, literals, is_generator, | 1607 isolate()->factory()->NewSharedFunctionInfo(name, literals, is_generator, |
| 1591 code, Handle<ScopeInfo>(fun->shared()->scope_info())); | 1608 code, Handle<ScopeInfo>(fun->shared()->scope_info()), |
| 1609 Handle<FixedArray>(fun->shared()->feedback_vector())); |
| 1592 shared->set_construct_stub(*construct_stub); | 1610 shared->set_construct_stub(*construct_stub); |
| 1593 | 1611 |
| 1594 // Copy the function data to the shared function info. | 1612 // Copy the function data to the shared function info. |
| 1595 shared->set_function_data(fun->shared()->function_data()); | 1613 shared->set_function_data(fun->shared()->function_data()); |
| 1596 int parameters = fun->shared()->formal_parameter_count(); | 1614 int parameters = fun->shared()->formal_parameter_count(); |
| 1597 shared->set_formal_parameter_count(parameters); | 1615 shared->set_formal_parameter_count(parameters); |
| 1598 | 1616 |
| 1599 EmitNewClosure(shared, false); | 1617 EmitNewClosure(shared, false); |
| 1600 } | 1618 } |
| 1601 | 1619 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 } | 1746 } |
| 1729 return true; | 1747 return true; |
| 1730 } | 1748 } |
| 1731 #endif // DEBUG | 1749 #endif // DEBUG |
| 1732 | 1750 |
| 1733 | 1751 |
| 1734 #undef __ | 1752 #undef __ |
| 1735 | 1753 |
| 1736 | 1754 |
| 1737 } } // namespace v8::internal | 1755 } } // namespace v8::internal |
| OLD | NEW |