Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(907)

Unified Diff: src/runtime/runtime-internal.cc

Issue 1294803004: Native context: run prologue.js before runtime.js (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: also change BUILD.gn Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-internal.cc
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc
index fa9ac008965efd918c8ed571281f71cbc58a0ccb..97edea53369078a99588b1832a6ad62dfeb07850 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -6,6 +6,7 @@
#include "src/arguments.h"
#include "src/bootstrapper.h"
+#include "src/conversions.h"
#include "src/debug/debug.h"
#include "src/frames-inl.h"
#include "src/messages.h"
@@ -44,6 +45,42 @@ RUNTIME_FUNCTION(Runtime_ImportExperimentalToRuntime) {
}
+RUNTIME_FUNCTION(Runtime_InstallFunctionsFromArray) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 3);
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
+ CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSArray, functions, 2);
+ RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
+
+ int num_items = NumberToInt32(functions->length()) / 2;
+ if (!object->IsJSGlobalObject() && object->HasFastProperties()) {
+ JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, num_items,
+ "InstallFunctions");
+ }
+
+ Handle<FixedArray> array(FixedArray::cast(functions->elements()));
+ for (int i = 0; i < num_items; ++i) {
+ RUNTIME_ASSERT(array->get(i * 2)->IsString());
+ RUNTIME_ASSERT(array->get(i * 2 + 1)->IsJSFunction());
+ Handle<String> name(String::cast(array->get(i * 2)));
+ Handle<JSFunction> fun(JSFunction::cast(array->get(i * 2 + 1)));
+ fun->shared()->set_name(*name);
+ RUNTIME_ASSERT(fun->RemovePrototype());
+ fun->shared()->set_native(true);
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate,
+ JSObject::SetOwnPropertyIgnoreAttributes(object, name, fun, attrs));
+ }
+
+ if (!object->IsJSGlobalObject()) {
+ JSObject::MigrateSlowToFast(object, 0, "InstallFunctions");
+ }
+
+ return isolate->heap()->undefined_value();
+}
+
+
RUNTIME_FUNCTION(Runtime_Throw) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
« no previous file with comments | « src/runtime/runtime.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698