Commit defa7459 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Make sure bound functions never make it into optimized code map.

This is one step torwards extracting an OptimizedCodeMap out from the
SharedFunctionInfo in order to have a more flexible implementation.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/1210523002

Cr-Commit-Position: refs/heads/master@{#29275}
parent 2161d397
......@@ -690,8 +690,6 @@ MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
Handle<JSFunction> function, BailoutId osr_ast_id) {
if (FLAG_cache_optimized_code) {
Handle<SharedFunctionInfo> shared(function->shared());
// Bound functions are not cached.
if (shared->bound()) return MaybeHandle<Code>();
DisallowHeapAllocation no_gc;
int index = shared->SearchOptimizedCodeMap(
function->context()->native_context(), osr_ast_id);
......@@ -723,12 +721,13 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
// Context specialization folds-in the context, so no sharing can occur.
if (code->is_turbofanned() && info->is_context_specializing()) return;
// Do not cache bound functions.
if (info->closure()->shared()->bound()) return;
// Cache optimized code.
if (FLAG_cache_optimized_code) {
Handle<JSFunction> function = info->closure();
Handle<SharedFunctionInfo> shared(function->shared());
// Do not cache bound functions.
if (shared->bound()) return;
Handle<FixedArray> literals(function->literals());
Handle<Context> native_context(function->context()->native_context());
SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code,
......
......@@ -9623,12 +9623,9 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
FixedArray* SharedFunctionInfo::GetLiteralsFromOptimizedCodeMap(int index) {
DCHECK(index > kEntriesStart);
FixedArray* code_map = FixedArray::cast(optimized_code_map());
if (!bound()) {
FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
DCHECK_NOT_NULL(cached_literals);
return cached_literals;
}
return NULL;
FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
DCHECK_NOT_NULL(cached_literals);
return cached_literals;
}
......
......@@ -396,6 +396,7 @@ RUNTIME_FUNCTION(Runtime_FunctionBindArguments) {
// TODO(lrn): Create bound function in C++ code from premade shared info.
bound_function->shared()->set_bound(true);
bound_function->shared()->set_optimized_code_map(Smi::FromInt(0));
bound_function->shared()->set_inferred_name(isolate->heap()->empty_string());
// Get all arguments of calling function (Function.prototype.bind).
int argc = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment