[factory] Remove deprecated JSFunction ctors

* Replace deprecated Factory::NewFunction* calls with JSFunctionBuilder.
* Drive-by: rename Factory::NewFunctionForTest to ..ForTesting (this is
  the correct suffix recognized by our tooling to ensure it's only
  called from tests).

Tbr: clemensb@chromium.org
Bug: v8:8888
Change-Id: I110063803e5b467bd91b75fe8fea2ca4174f2bcc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2529129
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71101}
This commit is contained in:
Jakob Gruber 2020-11-10 12:22:49 +01:00 committed by Commit Bot
parent 351ceee8c2
commit 074621e913
27 changed files with 120 additions and 163 deletions

View File

@ -653,8 +653,7 @@ Handle<JSFunction> ApiNatives::CreateApiFunction(
DCHECK(shared->HasSharedName());
Handle<JSFunction> result =
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared,
native_context);
Factory::JSFunctionBuilder{isolate, shared, native_context}.Build();
if (obj->remove_prototype()) {
DCHECK(prototype.is_null());

View File

@ -2053,8 +2053,9 @@ Local<Script> UnboundScript::BindToCurrentContext() {
i::Handle<i::SharedFunctionInfo>::cast(Utils::OpenHandle(this));
i::Isolate* isolate = function_info->GetIsolate();
i::Handle<i::JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
function_info, isolate->native_context());
i::Factory::JSFunctionBuilder{isolate, function_info,
isolate->native_context()}
.Build();
return ToApiHandle<Script>(function);
}

View File

@ -127,8 +127,10 @@ MaybeHandle<Object> CreateDynamicFunction(Isolate* isolate,
Handle<Map> map = Map::AsLanguageMode(isolate, initial_map, shared_info);
Handle<Context> context(function->context(), isolate);
function = isolate->factory()->NewFunctionFromSharedFunctionInfo(
map, shared_info, context, AllocationType::kYoung);
function = Factory::JSFunctionBuilder{isolate, shared_info, context}
.set_map(map)
.set_allocation_type(AllocationType::kYoung)
.Build();
}
return function;
}

View File

@ -220,6 +220,7 @@ BUILTIN(DateTimeFormatPrototypeFormatRangeToParts) {
}
namespace {
Handle<JSFunction> CreateBoundFunction(Isolate* isolate,
Handle<JSObject> object,
Builtins::Name builtin_id, int len) {
@ -238,11 +239,9 @@ Handle<JSFunction> CreateBoundFunction(Isolate* isolate,
info->set_internal_formal_parameter_count(len);
info->set_length(len);
Handle<Map> map = isolate->strict_function_without_prototype_map();
Handle<JSFunction> new_bound_function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(map, info, context);
return new_bound_function;
return Factory::JSFunctionBuilder{isolate, info, context}
.set_map(isolate->strict_function_without_prototype_map())
.Build();
}
/**
@ -381,6 +380,7 @@ Object CallOrConstructConstructor(BuiltinArguments args, Isolate* isolate,
RETURN_RESULT_OR_FAILURE(isolate,
T::New(isolate, map, locales, options, method));
}
} // namespace
// Intl.DisplayNames

View File

@ -2050,11 +2050,14 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
Handle<JSFunction> result;
if (eval_result.has_shared()) {
if (eval_result.has_feedback_cell()) {
result = isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_info, context, feedback_cell, AllocationType::kYoung);
result = Factory::JSFunctionBuilder{isolate, shared_info, context}
.set_feedback_cell(feedback_cell)
.set_allocation_type(AllocationType::kYoung)
.Build();
} else {
result = isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_info, context, AllocationType::kYoung);
result = Factory::JSFunctionBuilder{isolate, shared_info, context}
.set_allocation_type(AllocationType::kYoung)
.Build();
JSFunction::InitializeFeedbackCell(result, &is_compiled_scope);
if (allow_eval_cache) {
// Make sure to cache this result.
@ -2065,8 +2068,9 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
}
}
} else {
result = isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared_info, context, AllocationType::kYoung);
result = Factory::JSFunctionBuilder{isolate, shared_info, context}
.set_allocation_type(AllocationType::kYoung)
.Build();
JSFunction::InitializeFeedbackCell(result, &is_compiled_scope);
if (allow_eval_cache) {
// Add the SharedFunctionInfo and the LiteralsArray to the eval cache if
@ -2831,8 +2835,9 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
}
DCHECK(is_compiled_scope.is_compiled());
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
wrapped, context, AllocationType::kYoung);
return Factory::JSFunctionBuilder{isolate, wrapped, context}
.set_allocation_type(AllocationType::kYoung)
.Build();
}
// static

View File

@ -55,8 +55,7 @@ MaybeHandle<Object> DebugEvaluate::Global(Isolate* isolate,
Handle<Context> context = isolate->native_context();
Handle<JSFunction> fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(shared_info,
context);
Factory::JSFunctionBuilder{isolate, shared_info, context}.Build();
if (mode == debug::EvaluateGlobalMode::kDisableBreaksAndThrowOnSideEffect) {
isolate->debug()->StartSideEffectCheckMode();
}

View File

@ -3596,7 +3596,7 @@ Handle<Map> NewFunctionArgs::GetMap(Isolate* isolate) const {
UNREACHABLE();
}
Handle<JSFunction> Factory::NewFunctionForTest(Handle<String> name) {
Handle<JSFunction> Factory::NewFunctionForTesting(Handle<String> name) {
NewFunctionArgs args = NewFunctionArgs::ForFunctionWithoutCode(
name, isolate()->sloppy_function_map(), LanguageMode::kSloppy);
Handle<JSFunction> result = NewFunction(args);
@ -3683,45 +3683,6 @@ Handle<JSFunction> Factory::NewFunction(const NewFunctionArgs& args) {
return result;
}
Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<SharedFunctionInfo> info,
Handle<Context> context,
AllocationType allocation) {
// TODO(jgruber): Remove this function.
return JSFunctionBuilder{isolate(), info, context}
.set_map(map)
.set_allocation_type(allocation)
.Build();
}
Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> info, Handle<Context> context,
AllocationType allocation) {
// TODO(jgruber): Remove this function.
return JSFunctionBuilder{isolate(), info, context}
.set_allocation_type(allocation)
.Build();
}
Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> info, Handle<Context> context,
Handle<FeedbackCell> feedback_cell, AllocationType allocation) {
// TODO(jgruber): Remove this function.
return JSFunctionBuilder{isolate(), info, context}
.set_feedback_cell(feedback_cell)
.Build();
}
Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo(
Handle<Map> initial_map, Handle<SharedFunctionInfo> info,
Handle<Context> context, AllocationType allocation) {
// TODO(jgruber): Remove this function.
return JSFunctionBuilder{isolate(), info, context}
.set_map(initial_map)
.set_allocation_type(allocation)
.Build();
}
Factory::JSFunctionBuilder::JSFunctionBuilder(Isolate* isolate,
Handle<SharedFunctionInfo> sfi,
Handle<Context> context)

View File

@ -627,29 +627,7 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<JSFunction> NewFunction(const NewFunctionArgs& args);
// For testing only. Creates a sloppy function without code.
Handle<JSFunction> NewFunctionForTest(Handle<String> name);
// Function creation from SharedFunctionInfo.
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> function_info, Handle<Context> context,
Handle<FeedbackCell> feedback_cell,
AllocationType allocation = AllocationType::kOld);
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Handle<Map> initial_map, Handle<SharedFunctionInfo> function_info,
Handle<Context> context,
AllocationType allocation = AllocationType::kOld);
Handle<JSFunction> NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> function_info, Handle<Context> context,
AllocationType allocation = AllocationType::kOld);
// The choke-point for JSFunction creation. Handles allocation and
// initialization. All other utility methods call into this.
Handle<JSFunction> NewFunction(
Handle<Map> map, Handle<SharedFunctionInfo> info, Handle<Context> context,
AllocationType allocation = AllocationType::kOld);
Handle<JSFunction> NewFunctionForTesting(Handle<String> name);
// Create an External object for V8's external API.
Handle<JSObject> NewExternal(void* value);
@ -806,7 +784,7 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
}
// Helper class for creating JSFunction objects.
class JSFunctionBuilder final {
class V8_EXPORT_PRIVATE JSFunctionBuilder final {
public:
JSFunctionBuilder(Isolate* isolate, Handle<SharedFunctionInfo> sfi,
Handle<Context> context);

View File

@ -3893,7 +3893,7 @@ bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
// function before overwriting the context but since we're in a
// single-threaded environment it is not strictly necessary.
Handle<JSFunction> fun =
factory->NewFunctionFromSharedFunctionInfo(function_info, context);
Factory::JSFunctionBuilder{isolate, function_info, context}.Build();
// Call function using either the runtime object or the global
// object as the receiver. Provide no parameters.

View File

@ -431,8 +431,8 @@ bool SourceTextModule::FinishInstantiate(
Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(module->code()),
isolate);
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context());
Factory::JSFunctionBuilder{isolate, shared, isolate->native_context()}
.Build();
module->set_code(*function);
module->SetStatus(kInstantiating);
module->set_dfs_index(*dfs_index);

View File

@ -157,8 +157,9 @@ RUNTIME_FUNCTION(Runtime_DeclareModuleExports) {
index = Smi::ToInt(declarations->get(++i));
Handle<FeedbackCell> feedback_cell =
closure_feedback_cell_array->GetFeedbackCell(feedback_index);
value = *isolate->factory()->NewFunctionFromSharedFunctionInfo(
sfi, context, feedback_cell, AllocationType::kOld);
value = *Factory::JSFunctionBuilder(isolate, sfi, context)
.set_feedback_cell(feedback_cell)
.Build();
}
Cell::cast(exports->get(index - 1)).set_value(value);
@ -204,8 +205,9 @@ RUNTIME_FUNCTION(Runtime_DeclareGlobals) {
int index = Smi::ToInt(declarations->get(++i));
Handle<FeedbackCell> feedback_cell =
closure_feedback_cell_array->GetFeedbackCell(index);
value = isolate->factory()->NewFunctionFromSharedFunctionInfo(
sfi, context, feedback_cell, AllocationType::kOld);
value = Factory::JSFunctionBuilder(isolate, sfi, context)
.set_feedback_cell(feedback_cell)
.Build();
}
// Compute the property attributes. According to ECMA-262,
@ -561,10 +563,10 @@ RUNTIME_FUNCTION(Runtime_NewClosure) {
CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
CONVERT_ARG_HANDLE_CHECKED(FeedbackCell, feedback_cell, 1);
Handle<Context> context(isolate->context(), isolate);
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, context, feedback_cell, AllocationType::kYoung);
return *function;
return *Factory::JSFunctionBuilder{isolate, shared, context}
.set_feedback_cell(feedback_cell)
.set_allocation_type(AllocationType::kYoung)
.Build();
}
RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) {
@ -575,10 +577,10 @@ RUNTIME_FUNCTION(Runtime_NewClosure_Tenured) {
Handle<Context> context(isolate->context(), isolate);
// The caller ensures that we pretenure closures that are assigned
// directly to properties.
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, context, feedback_cell, AllocationType::kOld);
return *function;
return *Factory::JSFunctionBuilder{isolate, shared, context}
.set_feedback_cell(feedback_cell)
.set_allocation_type(AllocationType::kOld)
.Build();
}
RUNTIME_FUNCTION(Runtime_NewFunctionContext) {

View File

@ -1851,8 +1851,8 @@ Handle<WasmCapiFunction> WasmCapiFunction::New(
Handle<SharedFunctionInfo> shared =
isolate->factory()->NewSharedFunctionInfoForWasmCapiFunction(fun_data);
return Handle<WasmCapiFunction>::cast(
isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context()));
Factory::JSFunctionBuilder{isolate, shared, isolate->native_context()}
.Build());
}
WasmInstanceObject WasmExportedFunction::instance() {

View File

@ -39,8 +39,8 @@ static Handle<JSFunction> Compile(const char* source) {
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context());
return Factory::JSFunctionBuilder{isolate, shared, isolate->native_context()}
.Build();
}

View File

@ -375,7 +375,7 @@ TEST(GarbageCollection) {
{
HandleScope inner_scope(isolate);
// Allocate a function and keep it in global object's property.
Handle<JSFunction> function = factory->NewFunctionForTest(name);
Handle<JSFunction> function = factory->NewFunctionForTesting(name);
Object::SetProperty(isolate, global, name, function).Check();
// Allocate an object. Unrooted after leaving the scope.
Handle<JSObject> obj = factory->NewJSObject(function);
@ -746,7 +746,7 @@ TEST(FunctionAllocation) {
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function = factory->NewFunctionForTest(name);
Handle<JSFunction> function = factory->NewFunctionForTesting(name);
Handle<Smi> twenty_three(Smi::FromInt(23), isolate);
Handle<Smi> twenty_four(Smi::FromInt(24), isolate);
@ -849,7 +849,7 @@ TEST(JSObjectMaps) {
v8::HandleScope sc(CcTest::isolate());
Handle<String> name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function = factory->NewFunctionForTest(name);
Handle<JSFunction> function = factory->NewFunctionForTesting(name);
Handle<String> prop_name = factory->InternalizeUtf8String("theSlot");
Handle<JSObject> obj = factory->NewJSObject(function);

View File

@ -323,7 +323,7 @@ HEAP_TEST(InvalidatedSlotsFastToSlow) {
Handle<JSObject> obj;
{
AlwaysAllocateScopeForTesting always_allocate(heap);
Handle<JSFunction> function = factory->NewFunctionForTest(name);
Handle<JSFunction> function = factory->NewFunctionForTesting(name);
function->shared().set_expected_nof_properties(3);
obj = factory->NewJSObject(function, AllocationType::kOld);
}

View File

@ -171,7 +171,7 @@ HEAP_TEST(MarkCompactCollector) {
{ HandleScope scope(isolate);
// allocate a garbage
Handle<String> func_name = factory->InternalizeUtf8String("theFunction");
Handle<JSFunction> function = factory->NewFunctionForTest(func_name);
Handle<JSFunction> function = factory->NewFunctionForTesting(func_name);
Object::SetProperty(isolate, global, func_name, function).Check();
factory->NewJSObject(function);

View File

@ -233,8 +233,8 @@ TEST(PartiallyInitializedJSFunction) {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
HandleScope scope(isolate);
Handle<JSFunction> js_function =
factory->NewFunctionForTest(factory->NewStringFromAsciiChecked("test"));
Handle<JSFunction> js_function = factory->NewFunctionForTesting(
factory->NewStringFromAsciiChecked("test"));
Handle<Context> context = handle(js_function->context(), isolate);
// 1. Start simulating deserializaiton.

View File

@ -2269,7 +2269,7 @@ TEST(InterpreterInstanceOf) {
Zone* zone = handles.main_zone();
Factory* factory = isolate->factory();
Handle<i::String> name = factory->NewStringFromAsciiChecked("cons");
Handle<i::JSFunction> func = factory->NewFunctionForTest(name);
Handle<i::JSFunction> func = factory->NewFunctionForTesting(name);
Handle<i::JSObject> instance = factory->NewJSObject(func);
Handle<i::Object> other = factory->NewNumber(3.3333);
Handle<i::Object> cases[] = {Handle<i::Object>::cast(instance), other};

View File

@ -1294,7 +1294,7 @@ TEST(TryHasOwnProperty) {
{
// Dictionary mode object.
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> object = factory->NewJSObject(function);
AddProperties(object, names, arraysize(names));
JSObject::NormalizeProperties(isolate, object, CLEAR_INOBJECT_PROPERTIES, 0,
@ -1313,7 +1313,7 @@ TEST(TryHasOwnProperty) {
{
// Global object.
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
JSFunction::EnsureHasInitialMap(function);
function->initial_map().set_instance_type(JS_GLOBAL_OBJECT_TYPE);
function->initial_map().set_is_prototype_map(true);
@ -1364,7 +1364,7 @@ TEST(TryHasOwnProperty) {
{
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSProxy> object = factory->NewJSProxy(function, objects[0]);
CHECK_EQ(JS_PROXY_TYPE, object->map().instance_type());
ft.CheckTrue(object, names[0], expect_bailout);
@ -1437,11 +1437,11 @@ TEST(TryGetOwnProperty) {
factory->NewPrivateSymbol(),
};
Handle<Object> values[] = {
factory->NewFunctionForTest(factory->empty_string()),
factory->NewFunctionForTesting(factory->empty_string()),
factory->NewSymbol(),
factory->InternalizeUtf8String("a"),
CreateAccessorPair(&ft, "() => 188;", "() => 199;"),
factory->NewFunctionForTest(factory->InternalizeUtf8String("bb")),
factory->NewFunctionForTesting(factory->InternalizeUtf8String("bb")),
factory->InternalizeUtf8String("ccc"),
CreateAccessorPair(&ft, "() => 88;", nullptr),
handle(Smi::FromInt(1), isolate),
@ -1450,7 +1450,7 @@ TEST(TryGetOwnProperty) {
factory->NewHeapNumber(4.2),
handle(Smi::FromInt(153), isolate),
factory->NewJSObject(
factory->NewFunctionForTest(factory->empty_string())),
factory->NewFunctionForTesting(factory->empty_string())),
factory->NewPrivateSymbol(),
};
STATIC_ASSERT(arraysize(values) < arraysize(names));
@ -1501,7 +1501,7 @@ TEST(TryGetOwnProperty) {
{
// Dictionary mode object.
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> object = factory->NewJSObject(function);
AddProperties(object, names, arraysize(names), values, arraysize(values),
rand_gen.NextInt());
@ -1573,7 +1573,7 @@ TEST(TryGetOwnProperty) {
{
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSProxy> object = factory->NewJSProxy(function, objects[0]);
CHECK_EQ(JS_PROXY_TYPE, object->map().instance_type());
Handle<Object> value = ft.Call(object, names[0]).ToHandleChecked();
@ -1809,7 +1809,7 @@ TEST(TryLookupElement) {
{
Handle<JSArray> handler = factory->NewJSArray(0);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSProxy> object = factory->NewJSProxy(function, handler);
CHECK_EQ(JS_PROXY_TYPE, object->map().instance_type());
ft.CheckTrue(object, smi0, expect_bailout);

View File

@ -76,8 +76,8 @@ static Handle<JSFunction> Compile(const char* source) {
v8::ScriptCompiler::kNoCompileOptions,
ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE)
.ToHandleChecked();
return isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, isolate->native_context());
return Factory::JSFunctionBuilder{isolate, shared, isolate->native_context()}
.Build();
}

View File

@ -80,7 +80,7 @@ TEST(LinearSearchFlatObject) {
HandleScope handle_scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> js_object = factory->NewJSObject(function);
Handle<String> name = CcTest::MakeString("property");
Handle<Object> value = CcTest::MakeString("dummy_value");
@ -132,7 +132,7 @@ TEST(LinearSearchFlatObject_ManyElements) {
HandleScope handle_scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> js_object = factory->NewJSObject(function);
Handle<String> name = CcTest::MakeString("property");
Handle<Object> value = CcTest::MakeString("dummy_value");

View File

@ -78,7 +78,7 @@ TEST(ProtoWalkBackground) {
HandleScope handle_scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> js_object = factory->NewJSObject(function);
Handle<String> name = CcTest::MakeString("property");
Handle<Object> value = CcTest::MakeString("dummy_value");
@ -118,7 +118,7 @@ TEST(ProtoWalkBackground_DescriptorArrayWrite) {
HandleScope handle_scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> js_object = factory->NewJSObject(function);
Handle<String> name = CcTest::MakeString("property");
Handle<Object> value = CcTest::MakeString("dummy_value");
@ -165,7 +165,7 @@ TEST(ProtoWalkBackground_PrototypeChainWrite) {
HandleScope handle_scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<JSObject> js_object = factory->NewJSObject(function);
for (int i = 0; i < kNumHandles; i++) {

View File

@ -103,7 +103,7 @@ TEST(JSObjectAddingProperties) {
Handle<FixedArray> empty_fixed_array(factory->empty_fixed_array());
Handle<PropertyArray> empty_property_array(factory->empty_property_array());
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<Object> value(Smi::FromInt(42), isolate);
Handle<JSObject> object = factory->NewJSObject(function);
@ -133,7 +133,7 @@ TEST(JSObjectInObjectAddingProperties) {
Handle<FixedArray> empty_fixed_array(factory->empty_fixed_array());
Handle<PropertyArray> empty_property_array(factory->empty_property_array());
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
int nof_inobject_properties = 10;
// force in object properties by changing the expected_nof_properties
// (we always reserve 8 inobject properties slack on top).
@ -182,7 +182,7 @@ TEST(JSObjectAddingElements) {
Handle<FixedArray> empty_fixed_array(factory->empty_fixed_array());
Handle<PropertyArray> empty_property_array(factory->empty_property_array());
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
Handle<Object> value(Smi::FromInt(42), isolate);
Handle<JSObject> object = factory->NewJSObject(function);

View File

@ -50,11 +50,11 @@ static Handle<AccessorPair> CreateAccessorPair(bool with_getter,
Handle<AccessorPair> pair = factory->NewAccessorPair();
Handle<String> empty_string = factory->empty_string();
if (with_getter) {
Handle<JSFunction> func = factory->NewFunctionForTest(empty_string);
Handle<JSFunction> func = factory->NewFunctionForTesting(empty_string);
pair->set_getter(*func);
}
if (with_setter) {
Handle<JSFunction> func = factory->NewFunctionForTest(empty_string);
Handle<JSFunction> func = factory->NewFunctionForTesting(empty_string);
pair->set_setter(*func);
}
return pair;
@ -1585,7 +1585,7 @@ TEST(ReconfigureDataFieldAttribute_SameDataConstantAfterTargetMap) {
TestConfig() {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
js_func_ = factory->NewFunctionForTest(factory->empty_string());
js_func_ = factory->NewFunctionForTesting(factory->empty_string());
}
Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
@ -1626,10 +1626,14 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToDataFieldAfterTargetMap) {
CHECK(sloppy_map->is_stable());
js_func1_ =
factory->NewFunction(sloppy_map, info, isolate->native_context());
Factory::JSFunctionBuilder{isolate, info, isolate->native_context()}
.set_map(sloppy_map)
.Build();
js_func2_ =
factory->NewFunction(sloppy_map, info, isolate->native_context());
Factory::JSFunctionBuilder{isolate, info, isolate->native_context()}
.set_map(sloppy_map)
.Build();
}
Handle<Map> AddPropertyAtBranch(int branch_id, Expectations* expectations,
@ -1660,7 +1664,7 @@ TEST(ReconfigureDataFieldAttribute_DataConstantToAccConstantAfterTargetMap) {
TestConfig() {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
js_func_ = factory->NewFunctionForTest(factory->empty_string());
js_func_ = factory->NewFunctionForTesting(factory->empty_string());
pair_ = CreateAccessorPair(true, true);
}
@ -2741,7 +2745,7 @@ TEST(TransitionDataConstantToSameDataConstant) {
Factory* factory = isolate->factory();
Handle<JSFunction> js_func =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
TransitionToDataConstantOperator transition_op(js_func);
SameMapChecker checker;
@ -2763,11 +2767,15 @@ TEST(TransitionDataConstantToAnotherDataConstant) {
CHECK(sloppy_map->is_stable());
Handle<JSFunction> js_func1 =
factory->NewFunction(sloppy_map, info, isolate->native_context());
Factory::JSFunctionBuilder{isolate, info, isolate->native_context()}
.set_map(sloppy_map)
.Build();
TransitionToDataConstantOperator transition_op1(js_func1);
Handle<JSFunction> js_func2 =
factory->NewFunction(sloppy_map, info, isolate->native_context());
Factory::JSFunctionBuilder{isolate, info, isolate->native_context()}
.set_map(sloppy_map)
.Build();
TransitionToDataConstantOperator transition_op2(js_func2);
SameMapChecker checker;
@ -2784,7 +2792,7 @@ TEST(TransitionDataConstantToDataField) {
Handle<FieldType> any_type = FieldType::Any(isolate);
Handle<JSFunction> js_func1 =
factory->NewFunctionForTest(factory->empty_string());
factory->NewFunctionForTesting(factory->empty_string());
TransitionToDataConstantOperator transition_op1(js_func1);
Handle<Object> value2 = isolate->factory()->NewHeapNumber(0);

View File

@ -1677,8 +1677,8 @@ void TestCodeSerializerOnePlusOneImpl(bool verify_builtins_count = true) {
CHECK(Script::cast(copy->script()).source() == *copy_source);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<JSObject> global(isolate->context().global_object(), isolate);
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -1764,8 +1764,8 @@ TEST(CodeSerializerInternalizedString) {
isolate, orig_source, Handle<String>(), &script_data,
v8::ScriptCompiler::kNoCompileOptions);
Handle<JSFunction> orig_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
orig, isolate->native_context());
Factory::JSFunctionBuilder{isolate, orig, isolate->native_context()}
.Build();
Handle<Object> orig_result =
Execution::Call(isolate, orig_fun, global, 0, nullptr).ToHandleChecked();
CHECK(orig_result->IsInternalizedString());
@ -1782,8 +1782,8 @@ TEST(CodeSerializerInternalizedString) {
CHECK(Script::cast(copy->script()).source() == *copy_source);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
CHECK_NE(*orig_fun, *copy_fun);
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -1835,8 +1835,8 @@ TEST(CodeSerializerLargeCodeObject) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -1914,8 +1914,8 @@ TEST(CodeSerializerLargeCodeObjectWithIncrementalMarking) {
CcTest::CollectAllGarbage();
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -1964,8 +1964,8 @@ TEST(CodeSerializerLargeStrings) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -2038,8 +2038,8 @@ TEST(CodeSerializerThreeBigStrings) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
USE(Execution::Call(isolate, copy_fun, global, 0, nullptr));
@ -2156,8 +2156,8 @@ TEST(CodeSerializerExternalString) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -2220,7 +2220,8 @@ TEST(CodeSerializerLargeExternalString) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();
@ -2273,7 +2274,8 @@ TEST(CodeSerializerExternalScriptName) {
CHECK_NE(*orig, *copy);
Handle<JSFunction> copy_fun =
f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context());
Factory::JSFunctionBuilder{isolate, copy, isolate->native_context()}
.Build();
Handle<Object> copy_result =
Execution::Call(isolate, copy_fun, global, 0, nullptr).ToHandleChecked();

View File

@ -238,7 +238,7 @@ TEST(Regress2060a) {
Heap* heap = isolate->heap();
HandleScope scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->function_string());
factory->NewFunctionForTesting(factory->function_string());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakMap> weakmap = isolate->factory()->NewJSWeakMap();
@ -281,7 +281,7 @@ TEST(Regress2060b) {
Heap* heap = isolate->heap();
HandleScope scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->function_string());
factory->NewFunctionForTesting(factory->function_string());
// Start second old-space page so that keys land on evacuation candidate.
Page* first_page = heap->old_space()->first_page();

View File

@ -172,7 +172,7 @@ TEST(WeakSet_Regress2060a) {
Heap* heap = isolate->heap();
HandleScope scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->function_string());
factory->NewFunctionForTesting(factory->function_string());
Handle<JSObject> key = factory->NewJSObject(function);
Handle<JSWeakSet> weakset = AllocateJSWeakSet(isolate);
@ -215,7 +215,7 @@ TEST(WeakSet_Regress2060b) {
Heap* heap = isolate->heap();
HandleScope scope(isolate);
Handle<JSFunction> function =
factory->NewFunctionForTest(factory->function_string());
factory->NewFunctionForTesting(factory->function_string());
// Start second old-space page so that keys land on evacuation candidate.
Page* first_page = heap->old_space()->first_page();