Commit 2411bc94 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Harden %FunctionBindArguments wrt optimized code cache.

R=jkummerow@chromium.org
BUG=387627
LOG=N

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21936 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7f429e62
...@@ -1041,6 +1041,8 @@ MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( ...@@ -1041,6 +1041,8 @@ MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
BailoutId osr_ast_id) { BailoutId osr_ast_id) {
if (FLAG_cache_optimized_code) { if (FLAG_cache_optimized_code) {
Handle<SharedFunctionInfo> shared(function->shared()); Handle<SharedFunctionInfo> shared(function->shared());
// Bound functions are not cached.
if (shared->bound()) return MaybeHandle<Code>();
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
int index = shared->SearchOptimizedCodeMap( int index = shared->SearchOptimizedCodeMap(
function->context()->native_context(), osr_ast_id); function->context()->native_context(), osr_ast_id);
...@@ -1070,6 +1072,8 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { ...@@ -1070,6 +1072,8 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
if (FLAG_cache_optimized_code) { if (FLAG_cache_optimized_code) {
Handle<JSFunction> function = info->closure(); Handle<JSFunction> function = info->closure();
Handle<SharedFunctionInfo> shared(function->shared()); Handle<SharedFunctionInfo> shared(function->shared());
// Do not cache bound functions.
if (shared->bound()) return;
Handle<FixedArray> literals(function->literals()); Handle<FixedArray> literals(function->literals());
Handle<Context> native_context(function->context()->native_context()); Handle<Context> native_context(function->context()->native_context());
SharedFunctionInfo::AddToOptimizedCodeMap( SharedFunctionInfo::AddToOptimizedCodeMap(
......
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
function f() {}
%FunctionBindArguments(f, {}, undefined, 1);
f();
f();
%OptimizeFunctionOnNextCall(f);
f();
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