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

Side by Side Diff: src/runtime.cc

Issue 5699002: RFC: Switch to ast ids (instead of positions) for type feedback. (Closed)
Patch Set: Cleanup Created 10 years 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 6700 matching lines...) Expand 10 before | Expand all | Expand 10 after
6711 HandleScope scope; 6711 HandleScope scope;
6712 ASSERT(args.length() == 1); 6712 ASSERT(args.length() == 1);
6713 Handle<JSFunction> function = args.at<JSFunction>(0); 6713 Handle<JSFunction> function = args.at<JSFunction>(0);
6714 // If the function is not optimizable or debugger is active continue using the 6714 // If the function is not optimizable or debugger is active continue using the
6715 // code from the full compiler. 6715 // code from the full compiler.
6716 if (!function->shared()->code()->optimizable() || 6716 if (!function->shared()->code()->optimizable() ||
6717 Debug::has_break_points()) { 6717 Debug::has_break_points()) {
6718 function->ReplaceCode(function->shared()->code()); 6718 function->ReplaceCode(function->shared()->code());
6719 return function->code(); 6719 return function->code();
6720 } 6720 }
6721 if (CompileOptimized(function, AstNode::kNoNumber)) { 6721 if (CompileOptimized(function, kNoAstId)) {
6722 return function->code(); 6722 return function->code();
6723 } 6723 }
6724 function->ReplaceCode(function->shared()->code()); 6724 function->ReplaceCode(function->shared()->code());
6725 return Failure::Exception(); 6725 return Failure::Exception();
6726 } 6726 }
6727 6727
6728 6728
6729 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) { 6729 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) {
6730 HandleScope scope; 6730 HandleScope scope;
6731 ASSERT(args.length() == 1); 6731 ASSERT(args.length() == 1);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6839 // deoptimized so that we are currently in an unoptimized activation. 6839 // deoptimized so that we are currently in an unoptimized activation.
6840 // Check for optimized activations of this function. 6840 // Check for optimized activations of this function.
6841 JavaScriptFrameIterator it; 6841 JavaScriptFrameIterator it;
6842 while (succeeded && !it.done()) { 6842 while (succeeded && !it.done()) {
6843 JavaScriptFrame* frame = it.frame(); 6843 JavaScriptFrame* frame = it.frame();
6844 succeeded = !frame->is_optimized() || frame->function() != *function; 6844 succeeded = !frame->is_optimized() || frame->function() != *function;
6845 it.Advance(); 6845 it.Advance();
6846 } 6846 }
6847 } 6847 }
6848 6848
6849 int ast_id = AstNode::kNoNumber; 6849 AstId ast_id = kNoAstId;
6850 if (succeeded) { 6850 if (succeeded) {
6851 // The top JS function is this one, the PC is somewhere in the 6851 // The top JS function is this one, the PC is somewhere in the
6852 // unoptimized code. 6852 // unoptimized code.
6853 JavaScriptFrameIterator it; 6853 JavaScriptFrameIterator it;
6854 JavaScriptFrame* frame = it.frame(); 6854 JavaScriptFrame* frame = it.frame();
6855 ASSERT(frame->function() == *function); 6855 ASSERT(frame->function() == *function);
6856 ASSERT(frame->code() == *unoptimized); 6856 ASSERT(frame->code() == *unoptimized);
6857 ASSERT(unoptimized->contains(frame->pc())); 6857 ASSERT(unoptimized->contains(frame->pc()));
6858 6858
6859 // Use linear search of the unoptimized code's stack check table to find 6859 // Use linear search of the unoptimized code's stack check table to find
6860 // the AST id matching the PC. 6860 // the AST id matching the PC.
6861 Address start = unoptimized->instruction_start(); 6861 Address start = unoptimized->instruction_start();
6862 unsigned target_pc_offset = static_cast<unsigned>(frame->pc() - start); 6862 unsigned target_pc_offset = static_cast<unsigned>(frame->pc() - start);
6863 Address table_cursor = start + unoptimized->stack_check_table_start(); 6863 Address table_cursor = start + unoptimized->stack_check_table_start();
6864 uint32_t table_length = Memory::uint32_at(table_cursor); 6864 uint32_t table_length = Memory::uint32_at(table_cursor);
6865 table_cursor += kIntSize; 6865 table_cursor += kIntSize;
6866 for (unsigned i = 0; i < table_length; ++i) { 6866 for (unsigned i = 0; i < table_length; ++i) {
6867 // Table entries are (AST id, pc offset) pairs. 6867 // Table entries are (AST id, pc offset) pairs.
6868 uint32_t pc_offset = Memory::uint32_at(table_cursor + kIntSize); 6868 uint32_t pc_offset = Memory::uint32_at(table_cursor + kIntSize);
6869 if (pc_offset == target_pc_offset) { 6869 if (pc_offset == target_pc_offset) {
6870 ast_id = static_cast<int>(Memory::uint32_at(table_cursor)); 6870 ast_id = static_cast<AstId>(Memory::uint32_at(table_cursor));
6871 break; 6871 break;
6872 } 6872 }
6873 table_cursor += 2 * kIntSize; 6873 table_cursor += 2 * kIntSize;
6874 } 6874 }
6875 ASSERT(ast_id != AstNode::kNoNumber); 6875 ASSERT(ast_id != kNoAstId);
6876 if (FLAG_trace_osr) { 6876 if (FLAG_trace_osr) {
6877 PrintF("[replacing on-stack at AST id %d in ", ast_id); 6877 PrintF("[replacing on-stack at AST id %d in ", ast_id);
6878 function->PrintName(); 6878 function->PrintName();
6879 PrintF("]\n"); 6879 PrintF("]\n");
6880 } 6880 }
6881 6881
6882 // Try to compile the optimized code. A true return value from 6882 // Try to compile the optimized code. A true return value from
6883 // CompileOptimized means that compilation succeeded, not necessarily 6883 // CompileOptimized means that compilation succeeded, not necessarily
6884 // that optimization succeeded. 6884 // that optimization succeeded.
6885 if (CompileOptimized(function, ast_id) && function->IsOptimized()) { 6885 if (CompileOptimized(function, ast_id) && function->IsOptimized()) {
6886 DeoptimizationInputData* data = DeoptimizationInputData::cast( 6886 DeoptimizationInputData* data = DeoptimizationInputData::cast(
6887 function->code()->deoptimization_data()); 6887 function->code()->deoptimization_data());
6888 if (FLAG_trace_osr) { 6888 if (FLAG_trace_osr) {
6889 PrintF("[on-stack replacement offset %d in optimized code]\n", 6889 PrintF("[on-stack replacement offset %d in optimized code]\n",
6890 data->OsrPcOffset()->value()); 6890 data->OsrPcOffset()->value());
6891 } 6891 }
6892 ASSERT(data->OsrAstId()->value() == ast_id); 6892 ASSERT(static_cast<AstId>(data->OsrAstId()->value()) == ast_id);
6893 ASSERT(data->OsrPcOffset()->value() >= 0); 6893 ASSERT(data->OsrPcOffset()->value() >= 0);
6894 } else { 6894 } else {
6895 succeeded = false; 6895 succeeded = false;
6896 } 6896 }
6897 } 6897 }
6898 6898
6899 // Revert to the original stack checks in the original unoptimized code. 6899 // Revert to the original stack checks in the original unoptimized code.
6900 if (FLAG_trace_osr) { 6900 if (FLAG_trace_osr) {
6901 PrintF("[restoring original stack checks in "); 6901 PrintF("[restoring original stack checks in ");
6902 function->PrintName(); 6902 function->PrintName();
(...skipping 3875 matching lines...) Expand 10 before | Expand all | Expand 10 after
10778 } else { 10778 } else {
10779 // Handle last resort GC and make sure to allow future allocations 10779 // Handle last resort GC and make sure to allow future allocations
10780 // to grow the heap without causing GCs (if possible). 10780 // to grow the heap without causing GCs (if possible).
10781 Counters::gc_last_resort_from_js.Increment(); 10781 Counters::gc_last_resort_from_js.Increment();
10782 Heap::CollectAllGarbage(false); 10782 Heap::CollectAllGarbage(false);
10783 } 10783 }
10784 } 10784 }
10785 10785
10786 10786
10787 } } // namespace v8::internal 10787 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698