Commit 50436ad4 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Merge NewFunction and NewFunctionWithPrototype

BUG=
R=ishell@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21233 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ed64101b
This diff is collapsed.
......@@ -1246,14 +1246,9 @@ Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
type != JS_OBJECT_TYPE ||
instance_size != JSObject::kHeaderSize) {
Handle<Object> prototype = maybe_prototype.ToHandleChecked();
Handle<Map> initial_map = NewMap(type, instance_size);
if (prototype->IsJSObject()) {
JSObject::SetLocalPropertyIgnoreAttributes(
Handle<JSObject>::cast(prototype),
constructor_string(),
function,
DONT_ENUM).Assert();
} else if (!function->shared()->is_generator()) {
Handle<Map> initial_map = NewMap(
type, instance_size, GetInitialFastElementsKind());
if (prototype->IsTheHole() && !function->shared()->is_generator()) {
prototype = NewFunctionPrototype(function);
}
initial_map->set_prototype(*prototype);
......@@ -1278,30 +1273,6 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
}
Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
InstanceType type,
int instance_size,
Handle<JSObject> prototype,
Handle<Code> code,
bool force_initial_map) {
// Allocate the function.
Handle<JSFunction> function = NewFunction(name, code, prototype);
if (force_initial_map ||
type != JS_OBJECT_TYPE ||
instance_size != JSObject::kHeaderSize) {
Handle<Map> initial_map = NewMap(type,
instance_size,
GetInitialFastElementsKind());
function->set_initial_map(*initial_map);
initial_map->set_constructor(*function);
}
JSFunction::SetPrototype(function, prototype);
return function;
}
Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
// Make sure to use globals from the function's context, since the function
// can be from a different context.
......@@ -2151,6 +2122,13 @@ Handle<JSFunction> Factory::CreateApiFunction(
ASSERT(!result->has_prototype());
return result;
}
JSObject::SetLocalPropertyIgnoreAttributes(
handle(JSObject::cast(result->prototype())),
constructor_string(),
result,
DONT_ENUM).Assert();
// Down from here is only valid for API functions that can be used as a
// constructor (don't set the "remove prototype" flag).
......
......@@ -476,13 +476,6 @@ class Factory V8_FINAL {
Handle<Code> code,
bool force_initial_map);
Handle<JSFunction> NewFunctionWithPrototype(Handle<String> name,
InstanceType type,
int instance_size,
Handle<JSObject> prototype,
Handle<Code> code,
bool force_initial_map);
// Create a serialized scope info.
Handle<ScopeInfo> NewScopeInfo(int length);
......
......@@ -542,7 +542,7 @@ void JSGlobalProxy::JSGlobalProxyVerify() {
VerifyObjectField(JSGlobalProxy::kNativeContextOffset);
// Make sure that this object has no properties, elements.
CHECK_EQ(0, properties()->length());
CHECK(HasFastObjectElements());
CHECK(HasFastSmiElements());
CHECK_EQ(0, FixedArray::cast(elements())->length());
}
......
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