Reviewers: Igor Sheludko,

Message:
PTAL

Description:
Always pass in code to NewFunctionWithoutPrototype

BUG=

Please review this at https://codereview.chromium.org/239053007/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+9, -29 lines):
  M src/bootstrapper.cc
  M src/factory.h
  M src/factory.cc


Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index c373e52fcf31071cbb22f4df018fdc4d5f30dd3b..b6084c080389d7958c3f046e0a3b14b9e23c3613 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -484,15 +484,12 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
   // 262 15.3.4.
   Handle<String> empty_string =
       factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty"));
+  Handle<Code> code =
+      Handle<Code>(isolate->builtins()->builtin(Builtins::kEmptyFunction));
   Handle<JSFunction> empty_function =
-      factory->NewFunctionWithoutPrototype(empty_string, SLOPPY);
+      factory->NewFunctionWithoutPrototype(empty_string, code);

   // --- E m p t y ---
-  Handle<Code> code =
-      Handle<Code>(isolate->builtins()->builtin(
-          Builtins::kEmptyFunction));
-  empty_function->set_code(*code);
-  empty_function->shared()->set_code(*code);
   Handle<String> source =
       factory->NewStringFromOneByte(STATIC_ASCII_VECTOR("() {}"));
   Handle<Script> script = factory->NewScript(source);
@@ -567,13 +564,11 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
   if (throw_type_error_function.is_null()) {
     Handle<String> name = factory()->InternalizeOneByteString(
         STATIC_ASCII_VECTOR("ThrowTypeError"));
-    throw_type_error_function =
-      factory()->NewFunctionWithoutPrototype(name, SLOPPY);
     Handle<Code> code(isolate()->builtins()->builtin(
         Builtins::kStrictModePoisonPill));
+    throw_type_error_function =
+        factory()->NewFunctionWithoutPrototype(name, code);
throw_type_error_function->set_map(native_context()->sloppy_function_map());
-    throw_type_error_function->set_code(*code);
-    throw_type_error_function->shared()->set_code(*code);
     throw_type_error_function->shared()->DontAdaptArguments();

     JSObject::PreventExtensions(throw_type_error_function).Assert();
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 988c171cd8c19523e9797e373ab16c5b184d1d23..c823f9ce111e6ede2d648a4c6057ca8d31f3d363 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1304,17 +1304,6 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
 }


-Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, - Handle<Code> code) {
-  Handle<JSFunction> function = NewFunctionWithoutPrototype(name, SLOPPY);
-  function->shared()->set_code(*code);
-  function->set_code(*code);
-  ASSERT(!function->has_initial_map());
-  ASSERT(!function->has_prototype());
-  return function;
-}
-
-
 Handle<ScopeInfo> Factory::NewScopeInfo(int length) {
   Handle<FixedArray> array = NewFixedArray(length, TENURED);
   array->set_map_no_write_barrier(*scope_info_map());
@@ -2025,13 +2014,12 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
 }


-Handle<JSFunction> Factory::NewFunctionWithoutPrototype(
-    Handle<String> name,
-    StrictMode strict_mode) {
+Handle<JSFunction> Factory::NewFunctionWithoutPrototype(Handle<String> name, + Handle<Code> code) {
   Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name);
+  info->set_code(*code);
   Handle<Context> context(isolate()->context()->native_context());
- Handle<JSFunction> fun = NewFunction(info, context, MaybeHandle<Object>());
-  return fun;
+  return NewFunction(info, context, MaybeHandle<Object>());
 }


Index: src/factory.h
diff --git a/src/factory.h b/src/factory.h
index 0c850613bb95b8c6df84f97d9a803bb3aed4377c..a104dc9f20c3cf98a7ece06b019fcbefc34f902d 100644
--- a/src/factory.h
+++ b/src/factory.h
@@ -442,9 +442,6 @@ class Factory V8_FINAL {
                                               bool force_initial_map);

   Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
-                                                 StrictMode strict_mode);
-
-  Handle<JSFunction> NewFunctionWithoutPrototype(Handle<String> name,
                                                  Handle<Code> code);

   // Create a serialized scope info.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to