Version 3.12.0
Fixed Chromium issues: 115100, 129628, 131994, 132727, 132741, 132742, 133211
Fixed V8 issues: 915, 1914, 2034, 2087, 2094, 2134, 2156, 2166, 2172, 2177, 2179, 2185
Added --extra-code flag to mksnapshot to load JS code into the VM before creating the snapshot.
Support 'restart call frame' command in the debugger.
Performance and stability improvements on all platforms.
git-svn-id: http://v8.googlecode.com/svn/trunk@11882 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/factory.cc b/src/factory.cc
index 28b318a..682125e 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -554,18 +554,44 @@
}
result->set_context(*context);
+
+ int index = FLAG_cache_optimized_code
+ ? function_info->SearchOptimizedCodeMap(context->global_context())
+ : -1;
if (!function_info->bound()) {
- int number_of_literals = function_info->num_literals();
- Handle<FixedArray> literals = NewFixedArray(number_of_literals, pretenure);
- if (number_of_literals > 0) {
- // Store the object, regexp and array functions in the literals
- // array prefix. These functions will be used when creating
- // object, regexp and array literals in this function.
- literals->set(JSFunction::kLiteralGlobalContextIndex,
- context->global_context());
+ if (index > 0) {
+ FixedArray* code_map =
+ FixedArray::cast(function_info->optimized_code_map());
+ FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
+ ASSERT(cached_literals != NULL);
+ ASSERT(function_info->num_literals() == 0 ||
+ (code_map->get(index - 1) ==
+ cached_literals->get(JSFunction::kLiteralGlobalContextIndex)));
+ result->set_literals(cached_literals);
+ } else {
+ int number_of_literals = function_info->num_literals();
+ Handle<FixedArray> literals =
+ NewFixedArray(number_of_literals, pretenure);
+ if (number_of_literals > 0) {
+ // Store the object, regexp and array functions in the literals
+ // array prefix. These functions will be used when creating
+ // object, regexp and array literals in this function.
+ literals->set(JSFunction::kLiteralGlobalContextIndex,
+ context->global_context());
+ }
+ result->set_literals(*literals);
}
- result->set_literals(*literals);
}
+
+ if (index > 0) {
+ // Caching of optimized code enabled and optimized code found.
+ Code* code = Code::cast(
+ FixedArray::cast(function_info->optimized_code_map())->get(index));
+ ASSERT(code != NULL);
+ result->ReplaceCode(code);
+ return result;
+ }
+
if (V8::UseCrankshaft() &&
FLAG_always_opt &&
result->is_compiled() &&
@@ -699,7 +725,7 @@
MaybeObject* maybe_arg = args->GetElement(i);
Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg));
const char* arg = *arg_str->ToCString();
- Vector<char> v2(p, space);
+ Vector<char> v2(p, static_cast<int>(space));
OS::StrNCpy(v2, arg, space);
space -= Min(space, strlen(arg));
p = &buffer[kBufferSize] - space;