Version 3.0.0.
Improved performance by (partially) addressing issue 957 on IA-32. Still needs more work for the other architectures.
git-svn-id: http://v8.googlecode.com/svn/trunk@5932 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/heap.cc b/src/heap.cc
index 26859d7..0497ad5 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -38,10 +38,12 @@
#include "mark-compact.h"
#include "natives.h"
#include "objects-visiting.h"
+#include "runtime-profiler.h"
#include "scanner-base.h"
#include "scopeinfo.h"
#include "snapshot.h"
#include "v8threads.h"
+#include "vm-state-inl.h"
#if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
#include "regexp-macro-assembler.h"
#include "arm/regexp-macro-assembler-arm.h"
@@ -839,6 +841,8 @@
ContextSlotCache::Clear();
DescriptorLookupCache::Clear();
+ RuntimeProfiler::MarkCompactPrologue(is_compacting);
+
CompilationCache::MarkCompactPrologue();
CompletelyClearInstanceofCache();
@@ -1049,6 +1053,14 @@
// Scavenge object reachable from the global contexts list directly.
scavenge_visitor.VisitPointer(BitCast<Object**>(&global_contexts_list_));
+ // Scavenge objects reachable from the runtime-profiler sampler
+ // window directly.
+ Object** sampler_window_address = RuntimeProfiler::SamplerWindowAddress();
+ int sampler_window_size = RuntimeProfiler::SamplerWindowSize();
+ scavenge_visitor.VisitPointers(
+ sampler_window_address,
+ sampler_window_address + sampler_window_size);
+
new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
UpdateNewSpaceReferencesInExternalStringTable(
@@ -1116,6 +1128,40 @@
}
+static Object* ProcessFunctionWeakReferences(Object* function,
+ WeakObjectRetainer* retainer) {
+ Object* head = Heap::undefined_value();
+ JSFunction* tail = NULL;
+ Object* candidate = function;
+ while (!candidate->IsUndefined()) {
+ // Check whether to keep the candidate in the list.
+ JSFunction* candidate_function = reinterpret_cast<JSFunction*>(candidate);
+ Object* retain = retainer->RetainAs(candidate);
+ if (retain != NULL) {
+ if (head->IsUndefined()) {
+ // First element in the list.
+ head = candidate_function;
+ } else {
+ // Subsequent elements in the list.
+ ASSERT(tail != NULL);
+ tail->set_next_function_link(candidate_function);
+ }
+ // Retained function is new tail.
+ tail = candidate_function;
+ }
+ // Move to next element in the list.
+ candidate = candidate_function->next_function_link();
+ }
+
+ // Terminate the list if there is one or more elements.
+ if (tail != NULL) {
+ tail->set_next_function_link(Heap::undefined_value());
+ }
+
+ return head;
+}
+
+
void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) {
Object* head = undefined_value();
Context* tail = NULL;
@@ -1137,6 +1183,15 @@
}
// Retained context is new tail.
tail = candidate_context;
+
+ // Process the weak list of optimized functions for the context.
+ Object* function_list_head =
+ ProcessFunctionWeakReferences(
+ candidate_context->get(Context::OPTIMIZED_FUNCTIONS_LIST),
+ retainer);
+ candidate_context->set_unchecked(Context::OPTIMIZED_FUNCTIONS_LIST,
+ function_list_head,
+ UPDATE_WRITE_BARRIER);
}
// Move to next element in the list.
candidate = candidate_context->get(Context::NEXT_CONTEXT_LINK);
@@ -1651,6 +1706,11 @@
}
set_byte_array_map(Map::cast(obj));
+ { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
+ set_empty_byte_array(ByteArray::cast(obj));
+
{ MaybeObject* maybe_obj =
AllocateMap(PIXEL_ARRAY_TYPE, PixelArray::kAlignedSize);
if (!maybe_obj->ToObject(&obj)) return false;
@@ -2245,9 +2305,11 @@
share->set_debug_info(undefined_value());
share->set_inferred_name(empty_string());
share->set_compiler_hints(0);
+ share->set_deopt_counter(Smi::FromInt(FLAG_deopt_every_n_times));
share->set_initial_map(undefined_value());
share->set_this_property_assignments_count(0);
share->set_this_property_assignments(undefined_value());
+ share->set_opt_count(0);
share->set_num_literals(0);
share->set_end_position(0);
share->set_function_token_position(0);
@@ -2666,6 +2728,7 @@
code->set_instruction_size(desc.instr_size);
code->set_relocation_info(ByteArray::cast(reloc_info));
code->set_flags(flags);
+ code->set_deoptimization_data(empty_fixed_array());
// Allow self references to created code object by patching the handle to
// point to the newly allocated Code object.
if (!self_reference.is_null()) {
@@ -2794,6 +2857,7 @@
function->set_prototype_or_initial_map(prototype);
function->set_context(undefined_value());
function->set_literals(empty_fixed_array());
+ function->set_next_function_link(undefined_value());
return function;
}