Revision: 3030 Author: [email protected] Date: Wed Oct 7 06:50:16 2009 Log: Version 1.3.15
Expand the maximum size of the code space to 512MB for 64-bit mode. Fixed a crash bug happening when starting profiling (issue http://crbug.com/23768). http://code.google.com/p/v8/source/detail?r=3030 Modified: /trunk /trunk/ChangeLog /trunk/src/debug.cc /trunk/src/heap.cc /trunk/src/log.cc /trunk/src/objects-inl.h /trunk/src/objects.h /trunk/src/regexp-macro-assembler-irregexp-inl.h /trunk/src/version.cc /trunk/test/cctest/test-log.cc /trunk/test/mjsunit/array-constructor.js /trunk/test/mjsunit/global-load-from-eval-in-with.js /trunk/test/mjsunit/local-load-from-eval.js /trunk/test/mjsunit/property-load-across-eval.js /trunk/test/mjsunit/regress/regress-269.js /trunk/test/mjsunit/regress/regress-334.js ======================================= --- /trunk/ChangeLog Wed Oct 7 02:00:33 2009 +++ /trunk/ChangeLog Wed Oct 7 06:50:16 2009 @@ -1,3 +1,11 @@ +2009-10-07: Version 1.3.15 + + Expand the maximum size of the code space to 512MB for 64-bit mode. + + Fixed a crash bug happening when starting profiling (issue + http://crbug.com/23768). + + 2009-10-07: Version 1.3.14 Added GetRealNamedProperty to the API to lookup real properties ======================================= --- /trunk/src/debug.cc Wed Oct 7 02:00:33 2009 +++ /trunk/src/debug.cc Wed Oct 7 06:50:16 2009 @@ -1675,22 +1675,6 @@ Handle<JSObject>(Debug::debug_context()->global()), 0, NULL, &caught_exception); } - - -// If an object given is an external string, check that the underlying -// resource is accessible. For other kinds of objects, always return true. -static bool IsExternalStringValid(Object* str) { - if (!str->IsString() || !StringShape(String::cast(str)).IsExternal()) { - return true; - } - if (String::cast(str)->IsAsciiRepresentation()) { - return ExternalAsciiString::cast(str)->resource() != NULL; - } else if (String::cast(str)->IsTwoByteRepresentation()) { - return ExternalTwoByteString::cast(str)->resource() != NULL; - } else { - return true; - } -} void Debug::CreateScriptCache() { @@ -1711,7 +1695,7 @@ while (iterator.has_next()) { HeapObject* obj = iterator.next(); ASSERT(obj != NULL); - if (obj->IsScript() && IsExternalStringValid(Script::cast(obj)->source())) { + if (obj->IsScript() && Script::cast(obj)->HasValidSource()) { script_cache_->Add(Handle<Script>(Script::cast(obj))); count++; } ======================================= --- /trunk/src/heap.cc Wed Oct 7 02:00:33 2009 +++ /trunk/src/heap.cc Wed Oct 7 06:50:16 2009 @@ -82,7 +82,7 @@ int Heap::semispace_size_ = 16*MB; int Heap::old_generation_size_ = 1*GB; int Heap::initial_semispace_size_ = 1*MB; -size_t Heap::code_range_size_ = 256*MB; +size_t Heap::code_range_size_ = 512*MB; #else int Heap::semispace_size_ = 8*MB; int Heap::old_generation_size_ = 512*MB; ======================================= --- /trunk/src/log.cc Tue Sep 22 03:00:30 2009 +++ /trunk/src/log.cc Wed Oct 7 06:50:16 2009 @@ -1070,37 +1070,33 @@ } -void Logger::LogCompiledFunctions() { - HandleScope scope; - Handle<SharedFunctionInfo>* sfis = NULL; +static int EnumerateCompiledFunctions(Handle<SharedFunctionInfo>* sfis) { + AssertNoAllocation no_alloc; int compiled_funcs_count = 0; - - { - AssertNoAllocation no_alloc; - - HeapIterator iterator; - while (iterator.has_next()) { - HeapObject* obj = iterator.next(); - ASSERT(obj != NULL); - if (obj->IsSharedFunctionInfo() - && SharedFunctionInfo::cast(obj)->is_compiled()) { - ++compiled_funcs_count; - } - } - - sfis = NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count); - iterator.reset(); - - int i = 0; - while (iterator.has_next()) { - HeapObject* obj = iterator.next(); - ASSERT(obj != NULL); - if (obj->IsSharedFunctionInfo() - && SharedFunctionInfo::cast(obj)->is_compiled()) { - sfis[i++] = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(obj)); - } - } - } + HeapIterator iterator; + while (iterator.has_next()) { + HeapObject* obj = iterator.next(); + ASSERT(obj != NULL); + if (!obj->IsSharedFunctionInfo()) continue; + SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); + if (sfi->is_compiled() + && (!sfi->script()->IsScript() + || Script::cast(sfi->script())->HasValidSource())) { + if (sfis != NULL) + sfis[compiled_funcs_count] = Handle<SharedFunctionInfo>(sfi); + ++compiled_funcs_count; + } + } + return compiled_funcs_count; +} + + +void Logger::LogCompiledFunctions() { + HandleScope scope; + const int compiled_funcs_count = EnumerateCompiledFunctions(NULL); + Handle<SharedFunctionInfo>* sfis = + NewArray< Handle<SharedFunctionInfo> >(compiled_funcs_count); + EnumerateCompiledFunctions(sfis); // During iteration, there can be heap allocation due to // GetScriptLineNumber call. ======================================= --- /trunk/src/objects-inl.h Tue Sep 22 03:00:30 2009 +++ /trunk/src/objects-inl.h Wed Oct 7 06:50:16 2009 @@ -2361,6 +2361,20 @@ kThisPropertyAssignmentsCountOffset) +bool Script::HasValidSource() { + Object* src = this->source(); + if (!src->IsString()) return true; + String* src_str = String::cast(src); + if (!StringShape(src_str).IsExternal()) return true; + if (src_str->IsAsciiRepresentation()) { + return ExternalAsciiString::cast(src)->resource() != NULL; + } else if (src_str->IsTwoByteRepresentation()) { + return ExternalTwoByteString::cast(src)->resource() != NULL; + } + return true; +} + + void SharedFunctionInfo::DontAdaptArguments() { ASSERT(code()->kind() == Code::BUILTIN); set_formal_parameter_count(kDontAdaptArgumentsSentinel); ======================================= --- /trunk/src/objects.h Wed Oct 7 02:00:33 2009 +++ /trunk/src/objects.h Wed Oct 7 06:50:16 2009 @@ -2998,6 +2998,10 @@ static inline Script* cast(Object* obj); + // If script source is an external string, check that the underlying + // resource is accessible. Otherwise, always return true. + inline bool HasValidSource(); + #ifdef DEBUG void ScriptPrint(); void ScriptVerify(); ======================================= --- /trunk/src/version.cc Wed Oct 7 02:00:33 2009 +++ /trunk/src/version.cc Wed Oct 7 06:50:16 2009 @@ -34,7 +34,7 @@ // cannot be changed without changing the SCons build script. #define MAJOR_VERSION 1 #define MINOR_VERSION 3 -#define BUILD_NUMBER 14 +#define BUILD_NUMBER 15 #define PATCH_LEVEL 0 #define CANDIDATE_VERSION false ======================================= --- /trunk/test/cctest/test-log.cc Wed Oct 7 02:00:33 2009 +++ /trunk/test/cctest/test-log.cc Wed Oct 7 06:50:16 2009 @@ -428,6 +428,50 @@ } #endif // __linux__ + + +// Test for issue http://crbug.com/23768 in Chromium. +// Heap can contain scripts with already disposed external sources. +// We need to verify that LogCompiledFunctions doesn't crash on them. +namespace { + +class SimpleExternalString : public v8::String::ExternalStringResource { + public: + explicit SimpleExternalString(const char* source) + : utf_source_(strlen(source)) { + for (int i = 0; i < utf_source_.length(); ++i) + utf_source_[i] = source[i]; + } + virtual ~SimpleExternalString() {} + virtual size_t length() const { return utf_source_.length(); } + virtual const uint16_t* data() const { return utf_source_.start(); } + private: + i::ScopedVector<uint16_t> utf_source_; +}; + +} // namespace + +TEST(Issue23768) { + v8::HandleScope scope; + v8::Handle<v8::Context> env = v8::Context::New(); + env->Enter(); + + SimpleExternalString source_ext_str("(function ext() {})();"); + v8::Local<v8::String> source = v8::String::NewExternal(&source_ext_str); + // Script needs to have a name in order to trigger InitLineEnds execution. + v8::Handle<v8::String> origin = v8::String::New("issue-23768-test"); + v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin); + CHECK(!evil_script.IsEmpty()); + CHECK(!evil_script->Run().IsEmpty()); + i::Handle<i::ExternalTwoByteString> i_source( + i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); + // This situation can happen if source was an external string disposed + // by its owner. + i_source->set_resource(NULL); + + // Must not crash. + i::Logger::LogCompiledFunctions(); +} static inline bool IsStringEqualTo(const char* r, const char* s) { --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
