From 3672624b4537189cc4979140e95efc5d25195d8a Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Tue, 23 Mar 2010 14:33:42 +0000 Subject: [PATCH] Fix pop push optimization to work with partial snapshots (correct registration of external references in Proxy objects). I moved the declaration of the two functions to stub-cache.h because with all the types they use it's hard to declare them anywhere else. But the actual definition is still in runtime.cc near to the place where they are used. Review URL: http://codereview.chromium.org/1079012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4231 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/stub-cache-arm.cc | 2 +- src/assembler.cc | 10 ++++++++++ src/assembler.h | 3 +++ src/heap-inl.h | 4 ++-- src/heap.cc | 4 ++-- src/heap.h | 2 +- src/ia32/stub-cache-ia32.cc | 2 +- src/runtime.cc | 37 ++++++++++++++++++++----------------- src/serialize.cc | 22 +++++++++++++++------- src/stub-cache.h | 16 ++++++++++++++++ src/x64/stub-cache-x64.cc | 2 +- 11 files changed, 72 insertions(+), 32 deletions(-) diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 29a4fe8..abf2f64 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -923,7 +923,7 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, // -- lr : return address // ----------------------------------- SharedFunctionInfo* function_info = function->shared(); - if (false && function_info->HasCustomCallGenerator()) { + if (function_info->HasCustomCallGenerator()) { CustomCallGenerator generator = ToCData(function_info->function_data()); return generator(this, object, holder, function, name, check); diff --git a/src/assembler.cc b/src/assembler.cc index aaf10ef..bb010c8 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -664,6 +664,16 @@ ExternalReference ExternalReference::scheduled_exception_address() { } +ExternalReference ExternalReference::compile_array_pop_call() { + return ExternalReference(FUNCTION_ADDR(CompileArrayPopCall)); +} + + +ExternalReference ExternalReference::compile_array_push_call() { + return ExternalReference(FUNCTION_ADDR(CompileArrayPushCall)); +} + + #ifdef V8_NATIVE_REGEXP ExternalReference ExternalReference::re_check_stack_guard_state() { diff --git a/src/assembler.h b/src/assembler.h index cde7d69..b4834e5 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -443,6 +443,9 @@ class ExternalReference BASE_EMBEDDED { static ExternalReference scheduled_exception_address(); + static ExternalReference compile_array_pop_call(); + static ExternalReference compile_array_push_call(); + Address address() const {return reinterpret_cast
(address_);} #ifdef ENABLE_DEBUGGER_SUPPORT diff --git a/src/heap-inl.h b/src/heap-inl.h index c4676fd..892c289 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -283,11 +283,11 @@ Object* Heap::PrepareForCompare(String* str) { const int length = str->length(); Object* obj = str->TryFlatten(); if (length <= kMaxAlwaysFlattenLength || - unflattended_strings_length_ >= kFlattenLongThreshold) { + unflattened_strings_length_ >= kFlattenLongThreshold) { return obj; } if (obj->IsFailure()) { - unflattended_strings_length_ += length; + unflattened_strings_length_ += length; } return str; } diff --git a/src/heap.cc b/src/heap.cc index 6de1af9..13ffa29 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -117,7 +117,7 @@ Heap::HeapState Heap::gc_state_ = NOT_IN_GC; int Heap::mc_count_ = 0; int Heap::gc_count_ = 0; -int Heap::unflattended_strings_length_ = 0; +int Heap::unflattened_strings_length_ = 0; int Heap::always_allocate_scope_depth_ = 0; int Heap::linear_allocation_scope_depth_ = 0; @@ -307,7 +307,7 @@ void Heap::ReportStatisticsAfterGC() { void Heap::GarbageCollectionPrologue() { TranscendentalCache::Clear(); gc_count_++; - unflattended_strings_length_ = 0; + unflattened_strings_length_ = 0; #ifdef DEBUG ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); allow_allocation(false); diff --git a/src/heap.h b/src/heap.h index ca9b50a..d37641c 100644 --- a/src/heap.h +++ b/src/heap.h @@ -980,7 +980,7 @@ class Heap : public AllStatic { static int gc_count_; // how many gc happened // Total length of the strings we failed to flatten since the last GC. - static int unflattended_strings_length_; + static int unflattened_strings_length_; #define ROOT_ACCESSOR(type, name, camel_name) \ static inline void set_##name(type* value) { \ diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index 7aad153..e554a31 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -1454,7 +1454,7 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, // ----------------------------------- SharedFunctionInfo* function_info = function->shared(); - if (false && function_info->HasCustomCallGenerator()) { + if (function_info->HasCustomCallGenerator()) { CustomCallGenerator generator = ToCData(function_info->function_data()); return generator(this, object, holder, function, name, check); diff --git a/src/runtime.cc b/src/runtime.cc index fde956a..b349815 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -1240,9 +1240,9 @@ static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) { static void SetCustomCallGenerator(Handle function, - CustomCallGenerator generator) { + ExternalReference* generator) { if (function->shared()->function_data()->IsUndefined()) { - function->shared()->set_function_data(*FromCData(generator)); + function->shared()->set_function_data(*FromCData(generator->address())); } } @@ -1250,7 +1250,7 @@ static void SetCustomCallGenerator(Handle function, static Handle InstallBuiltin(Handle holder, const char* name, Builtins::Name builtin_name, - CustomCallGenerator generator = NULL) { + ExternalReference* generator = NULL) { Handle key = Factory::LookupAsciiSymbol(name); Handle code(Builtins::builtin(builtin_name)); Handle optimized = Factory::NewFunction(key, @@ -1267,22 +1267,22 @@ static Handle InstallBuiltin(Handle holder, } -static Object* CompileArrayPushCall(CallStubCompiler* compiler, - Object* object, - JSObject* holder, - JSFunction* function, - String* name, - StubCompiler::CheckType check) { +Object* CompileArrayPushCall(CallStubCompiler* compiler, + Object* object, + JSObject* holder, + JSFunction* function, + String* name, + StubCompiler::CheckType check) { return compiler->CompileArrayPushCall(object, holder, function, name, check); } -static Object* CompileArrayPopCall(CallStubCompiler* compiler, - Object* object, - JSObject* holder, - JSFunction* function, - String* name, - StubCompiler::CheckType check) { +Object* CompileArrayPopCall(CallStubCompiler* compiler, + Object* object, + JSObject* holder, + JSFunction* function, + String* name, + StubCompiler::CheckType check) { return compiler->CompileArrayPopCall(object, holder, function, name, check); } @@ -1292,8 +1292,11 @@ static Object* Runtime_SpecialArrayFunctions(Arguments args) { ASSERT(args.length() == 1); CONVERT_ARG_CHECKED(JSObject, holder, 0); - InstallBuiltin(holder, "pop", Builtins::ArrayPop, CompileArrayPopCall); - InstallBuiltin(holder, "push", Builtins::ArrayPush, CompileArrayPushCall); + ExternalReference pop = ExternalReference::compile_array_pop_call(); + ExternalReference push = ExternalReference::compile_array_push_call(); + + InstallBuiltin(holder, "pop", Builtins::ArrayPop, &pop); + InstallBuiltin(holder, "push", Builtins::ArrayPush, &push); InstallBuiltin(holder, "shift", Builtins::ArrayShift); InstallBuiltin(holder, "unshift", Builtins::ArrayUnshift); InstallBuiltin(holder, "slice", Builtins::ArraySlice); diff --git a/src/serialize.cc b/src/serialize.cc index 9d9ba08..980a1bc 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -409,36 +409,44 @@ void ExternalReferenceTable::PopulateTable() { UNCLASSIFIED, 19, "compare_doubles"); + Add(ExternalReference::compile_array_pop_call().address(), + UNCLASSIFIED, + 20, + "compile_array_pop"); + Add(ExternalReference::compile_array_push_call().address(), + UNCLASSIFIED, + 21, + "compile_array_push"); #ifdef V8_NATIVE_REGEXP Add(ExternalReference::re_case_insensitive_compare_uc16().address(), UNCLASSIFIED, - 20, + 22, "NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16()"); Add(ExternalReference::re_check_stack_guard_state().address(), UNCLASSIFIED, - 21, + 23, "RegExpMacroAssembler*::CheckStackGuardState()"); Add(ExternalReference::re_grow_stack().address(), UNCLASSIFIED, - 22, + 24, "NativeRegExpMacroAssembler::GrowStack()"); Add(ExternalReference::re_word_character_map().address(), UNCLASSIFIED, - 23, + 25, "NativeRegExpMacroAssembler::word_character_map"); #endif // Keyed lookup cache. Add(ExternalReference::keyed_lookup_cache_keys().address(), UNCLASSIFIED, - 24, + 26, "KeyedLookupCache::keys()"); Add(ExternalReference::keyed_lookup_cache_field_offsets().address(), UNCLASSIFIED, - 25, + 27, "KeyedLookupCache::field_offsets()"); Add(ExternalReference::transcendental_cache_array_address().address(), UNCLASSIFIED, - 26, + 28, "TranscendentalCache::caches()"); } diff --git a/src/stub-cache.h b/src/stub-cache.h index 0e986dd..0ca37e7 100644 --- a/src/stub-cache.h +++ b/src/stub-cache.h @@ -610,6 +610,22 @@ typedef Object* (*CustomCallGenerator)(CallStubCompiler* compiler, StubCompiler::CheckType check); +Object* CompileArrayPushCall(CallStubCompiler* compiler, + Object* object, + JSObject* holder, + JSFunction* function, + String* name, + StubCompiler::CheckType check); + + +Object* CompileArrayPopCall(CallStubCompiler* compiler, + Object* object, + JSObject* holder, + JSFunction* function, + String* name, + StubCompiler::CheckType check); + + } } // namespace v8::internal #endif // V8_STUB_CACHE_H_ diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 505c99f..aa620fc 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -783,7 +783,7 @@ Object* CallStubCompiler::CompileCallConstant(Object* object, // ----------------------------------- SharedFunctionInfo* function_info = function->shared(); - if (false && function_info->HasCustomCallGenerator()) { + if (function_info->HasCustomCallGenerator()) { CustomCallGenerator generator = ToCData(function_info->function_data()); return generator(this, object, holder, function, name, check); -- 2.7.4