Commit 4ba6f15e authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[objects] Remove obsolete uses of {ReplaceCode} methods.

R=rmcilroy@chromium.org

Change-Id: Id568afef0d6ac68170faa33ad9ab4bba97d40ce9
Reviewed-on: https://chromium-review.googlesource.com/690294
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48202}
parent b8b25e1c
...@@ -20,12 +20,12 @@ namespace { ...@@ -20,12 +20,12 @@ namespace {
void DisposeCompilationJob(CompilationJob* job, bool restore_function_code) { void DisposeCompilationJob(CompilationJob* job, bool restore_function_code) {
if (restore_function_code) { if (restore_function_code) {
Handle<JSFunction> function = job->compilation_info()->closure(); Handle<JSFunction> function = job->compilation_info()->closure();
function->ReplaceCode(function->shared()->code()); function->set_code(function->shared()->code());
if (function->IsInOptimizationQueue()) { if (function->IsInOptimizationQueue()) {
function->ClearOptimizationMarker(); function->ClearOptimizationMarker();
} }
// TODO(mvstanton): We can't call ensureliterals here due to allocation, // TODO(mvstanton): We can't call EnsureLiterals here due to allocation,
// but we probably shouldn't call ReplaceCode either, as this // but we probably shouldn't call set_code either, as this
// sometimes runs on the worker thread! // sometimes runs on the worker thread!
// JSFunction::EnsureLiterals(function); // JSFunction::EnsureLiterals(function);
} }
......
...@@ -288,7 +288,7 @@ void InstallUnoptimizedCode(CompilationInfo* compilation_info) { ...@@ -288,7 +288,7 @@ void InstallUnoptimizedCode(CompilationInfo* compilation_info) {
} }
DCHECK(!compilation_info->code().is_null()); DCHECK(!compilation_info->code().is_null());
shared->ReplaceCode(*compilation_info->code()); shared->set_code(*compilation_info->code());
if (compilation_info->has_bytecode_array()) { if (compilation_info->has_bytecode_array()) {
DCHECK(!shared->HasBytecodeArray()); // Only compiled once. DCHECK(!shared->HasBytecodeArray()); // Only compiled once.
DCHECK(!compilation_info->has_asm_wasm_data()); DCHECK(!compilation_info->has_asm_wasm_data());
...@@ -734,7 +734,7 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) { ...@@ -734,7 +734,7 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) {
compilation_info->closure()->ShortPrint(); compilation_info->closure()->ShortPrint();
PrintF("]\n"); PrintF("]\n");
} }
compilation_info->closure()->ReplaceCode(*compilation_info->code()); compilation_info->closure()->set_code(*compilation_info->code());
return CompilationJob::SUCCEEDED; return CompilationJob::SUCCEEDED;
} }
} }
...@@ -746,7 +746,7 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) { ...@@ -746,7 +746,7 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) {
PrintF(" because: %s]\n", PrintF(" because: %s]\n",
GetBailoutReason(compilation_info->bailout_reason())); GetBailoutReason(compilation_info->bailout_reason()));
} }
compilation_info->closure()->ReplaceCode(shared->code()); compilation_info->closure()->set_code(shared->code());
// Clear the InOptimizationQueue marker, if it exists. // Clear the InOptimizationQueue marker, if it exists.
if (compilation_info->closure()->IsInOptimizationQueue()) { if (compilation_info->closure()->IsInOptimizationQueue()) {
compilation_info->closure()->ClearOptimizationMarker(); compilation_info->closure()->ClearOptimizationMarker();
...@@ -952,7 +952,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { ...@@ -952,7 +952,7 @@ bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) {
} }
// Install code on closure. // Install code on closure.
function->ReplaceCode(*code); function->set_code(*code);
// Check postconditions on success. // Check postconditions on success.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
...@@ -978,7 +978,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function, ...@@ -978,7 +978,7 @@ bool Compiler::CompileOptimized(Handle<JSFunction> function,
} }
// Install code on closure. // Install code on closure.
function->ReplaceCode(*code); function->set_code(*code);
// Check postconditions on success. // Check postconditions on success.
DCHECK(!isolate->has_pending_exception()); DCHECK(!isolate->has_pending_exception());
...@@ -1507,7 +1507,7 @@ void Compiler::PostInstantiation(Handle<JSFunction> function, ...@@ -1507,7 +1507,7 @@ void Compiler::PostInstantiation(Handle<JSFunction> function,
// Caching of optimized code enabled and optimized code found. // Caching of optimized code enabled and optimized code found.
DCHECK(!code->marked_for_deoptimization()); DCHECK(!code->marked_for_deoptimization());
DCHECK(function->shared()->is_compiled()); DCHECK(function->shared()->is_compiled());
function->ReplaceCode(code); function->set_code(code);
} }
} }
} }
......
...@@ -3649,7 +3649,7 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt( ...@@ -3649,7 +3649,7 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
object->set_shared(SharedFunctionInfo::cast(*shared)); object->set_shared(SharedFunctionInfo::cast(*shared));
object->set_context(Context::cast(*context)); object->set_context(Context::cast(*context));
object->set_feedback_vector_cell(Cell::cast(*vector_cell)); object->set_feedback_vector_cell(Cell::cast(*vector_cell));
object->ReplaceCode(Code::cast(*code)); object->set_code(Code::cast(*code));
int in_object_properties = map->GetInObjectProperties(); int in_object_properties = map->GetInObjectProperties();
for (int i = 0; i < in_object_properties; ++i) { for (int i = 0; i < in_object_properties; ++i) {
Handle<Object> value = materializer.FieldAt(value_index); Handle<Object> value = materializer.FieldAt(value_index);
......
...@@ -4657,11 +4657,6 @@ void JSFunction::SetOptimizationMarker(OptimizationMarker marker) { ...@@ -4657,11 +4657,6 @@ void JSFunction::SetOptimizationMarker(OptimizationMarker marker) {
feedback_vector()->SetOptimizationMarker(marker); feedback_vector()->SetOptimizationMarker(marker);
} }
// TODO(jupvfranco): Get rid of this function and use set_code instead.
void JSFunction::ReplaceCode(Code* code) {
set_code(code);
}
bool JSFunction::has_feedback_vector() const { bool JSFunction::has_feedback_vector() const {
return !feedback_vector_cell()->value()->IsUndefined(GetIsolate()); return !feedback_vector_cell()->value()->IsUndefined(GetIsolate());
} }
......
...@@ -4836,7 +4836,6 @@ class JSFunction: public JSObject { ...@@ -4836,7 +4836,6 @@ class JSFunction: public JSObject {
inline Code* code(); inline Code* code();
inline void set_code(Code* code); inline void set_code(Code* code);
inline void set_code_no_write_barrier(Code* code); inline void set_code_no_write_barrier(Code* code);
inline void ReplaceCode(Code* code);
// Get the abstract code associated with the function, which will either be // Get the abstract code associated with the function, which will either be
// a Code object or a BytecodeArray. // a Code object or a BytecodeArray.
......
...@@ -214,12 +214,6 @@ void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) { ...@@ -214,12 +214,6 @@ void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode); CONDITIONAL_WRITE_BARRIER(value->GetHeap(), this, kCodeOffset, value, mode);
} }
void SharedFunctionInfo::ReplaceCode(Code* value) {
// TODO(mvstanton): just use set_code() directly everywhere, since ReplaceCode
// offers nothing extra.
set_code(value);
}
bool SharedFunctionInfo::IsInterpreted() const { bool SharedFunctionInfo::IsInterpreted() const {
return code()->is_interpreter_trampoline_builtin(); return code()->is_interpreter_trampoline_builtin();
} }
......
...@@ -58,8 +58,6 @@ class SharedFunctionInfo : public HeapObject { ...@@ -58,8 +58,6 @@ class SharedFunctionInfo : public HeapObject {
// optimized. // optimized.
inline bool IsInterpreted() const; inline bool IsInterpreted() const;
inline void ReplaceCode(Code* code);
// Set up the link between shared function info and the script. The shared // Set up the link between shared function info and the script. The shared
// function info is added to the list on the script. // function info is added to the list on the script.
V8_EXPORT_PRIVATE static void SetScript( V8_EXPORT_PRIVATE static void SetScript(
......
...@@ -119,10 +119,10 @@ RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) { ...@@ -119,10 +119,10 @@ RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) {
function->shared()->set_is_asm_wasm_broken(true); function->shared()->set_is_asm_wasm_broken(true);
DCHECK(function->code() == DCHECK(function->code() ==
isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)); isolate->builtins()->builtin(Builtins::kInstantiateAsmJs));
function->ReplaceCode(isolate->builtins()->builtin(Builtins::kCompileLazy)); function->set_code(isolate->builtins()->builtin(Builtins::kCompileLazy));
if (function->shared()->code() == if (function->shared()->code() ==
isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) { isolate->builtins()->builtin(Builtins::kInstantiateAsmJs)) {
function->shared()->ReplaceCode( function->shared()->set_code(
isolate->builtins()->builtin(Builtins::kCompileLazy)); isolate->builtins()->builtin(Builtins::kCompileLazy));
} }
return Smi::kZero; return Smi::kZero;
...@@ -288,7 +288,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { ...@@ -288,7 +288,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) {
} }
if (!function->IsOptimized()) { if (!function->IsOptimized()) {
function->ReplaceCode(function->shared()->code()); function->set_code(function->shared()->code());
} }
return NULL; return NULL;
} }
......
...@@ -136,7 +136,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) { ...@@ -136,7 +136,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
// Set the code, scope info, formal parameter count, and the length // Set the code, scope info, formal parameter count, and the length
// of the target shared function info. // of the target shared function info.
target_shared->ReplaceCode(source_shared->code()); target_shared->set_code(source_shared->code());
if (source_shared->HasBytecodeArray()) { if (source_shared->HasBytecodeArray()) {
target_shared->set_bytecode_array(source_shared->bytecode_array()); target_shared->set_bytecode_array(source_shared->bytecode_array());
} }
...@@ -162,7 +162,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) { ...@@ -162,7 +162,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) {
SharedFunctionInfo::SetScript(target_shared, source_script); SharedFunctionInfo::SetScript(target_shared, source_script);
// Set the code of the target function. // Set the code of the target function.
target->ReplaceCode(source_shared->code()); target->set_code(source_shared->code());
Handle<Context> context(source->context()); Handle<Context> context(source->context());
target->set_context(*context); target->set_context(*context);
......
...@@ -236,7 +236,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { ...@@ -236,7 +236,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) {
if (function->HasOptimizedCode()) { if (function->HasOptimizedCode()) {
if (!function->IsInterpreted()) { if (!function->IsInterpreted()) {
// For non I+TF path, install a shim which checks the optimization marker. // For non I+TF path, install a shim which checks the optimization marker.
function->ReplaceCode( function->set_code(
isolate->builtins()->builtin(Builtins::kCheckOptimizationMarker)); isolate->builtins()->builtin(Builtins::kCheckOptimizationMarker));
} }
DCHECK(function->ChecksOptimizationMarker()); DCHECK(function->ChecksOptimizationMarker());
......
...@@ -43,7 +43,7 @@ FunctionTester::FunctionTester(Handle<Code> code, int param_count) ...@@ -43,7 +43,7 @@ FunctionTester::FunctionTester(Handle<Code> code, int param_count)
flags_(0) { flags_(0) {
CHECK(!code.is_null()); CHECK(!code.is_null());
Compile(function); Compile(function);
function->ReplaceCode(*code); function->set_code(*code);
} }
FunctionTester::FunctionTester(Handle<Code> code) : FunctionTester(code, 0) {} FunctionTester::FunctionTester(Handle<Code> code) : FunctionTester(code, 0) {}
...@@ -156,7 +156,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { ...@@ -156,7 +156,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
CHECK(!code.is_null()); CHECK(!code.is_null());
info.dependencies()->Commit(code); info.dependencies()->Commit(code);
info.context()->native_context()->AddOptimizedCode(*code); info.context()->native_context()->AddOptimizedCode(*code);
function->ReplaceCode(*code); function->set_code(*code);
return function; return function;
} }
...@@ -170,7 +170,7 @@ Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { ...@@ -170,7 +170,7 @@ Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph);
CHECK(!code.is_null()); CHECK(!code.is_null());
function->ReplaceCode(*code); function->set_code(*code);
return function; return function;
} }
......
...@@ -123,7 +123,7 @@ class BytecodeGraphTester { ...@@ -123,7 +123,7 @@ class BytecodeGraphTester {
CompilationInfo compilation_info(&zone, function->GetIsolate(), script, CompilationInfo compilation_info(&zone, function->GetIsolate(), script,
shared, function); shared, function);
Handle<Code> code = Pipeline::GenerateCodeForTesting(&compilation_info); Handle<Code> code = Pipeline::GenerateCodeForTesting(&compilation_info);
function->ReplaceCode(*code); function->set_code(*code);
return function; return function;
} }
......
...@@ -145,8 +145,8 @@ TEST(StressJS) { ...@@ -145,8 +145,8 @@ TEST(StressJS) {
// Force the creation of an initial map and set the code to // Force the creation of an initial map and set the code to
// something empty. // something empty.
factory->NewJSObject(function); factory->NewJSObject(function);
function->ReplaceCode(CcTest::i_isolate()->builtins()->builtin( function->set_code(
Builtins::kEmptyFunction)); CcTest::i_isolate()->builtins()->builtin(Builtins::kEmptyFunction));
// Patch the map to have an accessor for "get". // Patch the map to have an accessor for "get".
Handle<Map> map(function->initial_map()); Handle<Map> map(function->initial_map());
Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
......
...@@ -5048,8 +5048,8 @@ static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -5048,8 +5048,8 @@ static void RemoveCodeAndGC(const v8::FunctionCallbackInfo<v8::Value>& args) {
Handle<Object> obj = v8::Utils::OpenHandle(*args[0]); Handle<Object> obj = v8::Utils::OpenHandle(*args[0]);
Handle<JSFunction> fun = Handle<JSFunction>::cast(obj); Handle<JSFunction> fun = Handle<JSFunction>::cast(obj);
fun->shared()->ClearBytecodeArray(); // Bytecode is code too. fun->shared()->ClearBytecodeArray(); // Bytecode is code too.
fun->ReplaceCode(*BUILTIN_CODE(isolate, CompileLazy)); fun->set_code(*BUILTIN_CODE(isolate, CompileLazy));
fun->shared()->ReplaceCode(*BUILTIN_CODE(isolate, CompileLazy)); fun->shared()->set_code(*BUILTIN_CODE(isolate, CompileLazy));
CcTest::CollectAllAvailableGarbage(); CcTest::CollectAllAvailableGarbage();
} }
......
...@@ -110,8 +110,7 @@ class InterpreterTester { ...@@ -110,8 +110,7 @@ class InterpreterTester {
source += "){})"; source += "){})";
function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(source.c_str())))); *v8::Local<v8::Function>::Cast(CompileRun(source.c_str()))));
function->ReplaceCode( function->set_code(*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline));
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline));
} }
if (!bytecode_.is_null()) { if (!bytecode_.is_null()) {
......
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