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

Unified Diff: src/bootstrapper.cc

Issue 90643003: Experimental implementation: Exposing SIMD instructions into JavaScript Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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/ast.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 67b579899fd4ea265fae4c3de22fb87e708a3afc..bea7b951d18aba275857304340ad11740bd84f93 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -210,6 +210,7 @@ class Genesis BASE_EMBEDDED {
ElementsKind elementsKind);
bool InstallExperimentalNatives();
void InstallBuiltinFunctionIds();
+ void InstallExperimentalSIMDBuiltinFunctionIds();
void InstallJSFunctionResultCaches();
void InitializeNormalizedMapCaches();
@@ -1438,6 +1439,41 @@ void Genesis::InitializeExperimentalGlobal() {
generator_result_map->instance_size());
native_context()->set_generator_result_map(*generator_result_map);
}
+
+ if (FLAG_simd_object) {
+ // --- f l o a t 3 2 x 4 ---
+ Handle<JSFunction> float32x4_fun =
+ InstallFunction(global, "float32x4", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+ native_context()->set_float32x4_function(*float32x4_fun);
+ InstallFunction(float32x4_fun, "zero", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+ InstallFunction(float32x4_fun, "splat", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+
+ // --- u i n t 3 2 x 4 ---
+ Handle<JSFunction> int32x4_fun =
+ InstallFunction(global, "int32x4", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+ native_context()->set_int32x4_function(*int32x4_fun);
+ InstallFunction(int32x4_fun, "bool", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+ InstallFunction(int32x4_fun, "splat", JS_VALUE_TYPE, JSValue::kSize,
+ isolate()->initial_object_prototype(),
+ Builtins::kIllegal, true, true);
+
+ Handle<JSFunction> float32x4_array_fun = InstallTypedArray("Float32x4Array",
+ EXTERNAL_FLOAT32x4_ELEMENTS);
+ native_context()->set_float32x4_array_fun(*float32x4_array_fun);
+ Handle<JSFunction> int32x4_array_fun = InstallTypedArray("Int32x4Array",
+ EXTERNAL_INT32x4_ELEMENTS);
+ native_context()->set_int32x4_array_fun(*int32x4_array_fun);
+ }
}
@@ -2069,6 +2105,22 @@ bool Genesis::InstallExperimentalNatives() {
"native harmony-math.js") == 0) {
if (!CompileExperimentalBuiltin(isolate(), i)) return false;
}
+ if (FLAG_simd_object &&
+ strcmp(ExperimentalNatives::GetScriptName(i).start(),
+ "native simd128.js") == 0) {
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
+ InstallExperimentalSIMDBuiltinFunctionIds();
+ // Store the map for the float32x4 and int32x4 function prototype after
+ // the float32x4 and int32x4 function has been set up.
+ JSObject* float32x4_function_prototype = JSObject::cast(
+ native_context()->float32x4_function()->instance_prototype());
+ native_context()->set_float32x4_function_prototype_map(
+ float32x4_function_prototype->map());
+ JSObject* int32x4_function_prototype = JSObject::cast(
+ native_context()->int32x4_function()->instance_prototype());
+ native_context()->set_int32x4_function_prototype_map(
+ int32x4_function_prototype->map());
+ }
}
InstallExperimentalNativeFunctions();
@@ -2097,6 +2149,33 @@ static Handle<JSObject> ResolveBuiltinIdHolder(
}
+static Handle<JSObject> ResolveBuiltinSIMDIdHolder(
+ Handle<Context> native_context,
+ const char* holder_expr) {
+ Isolate* isolate = native_context->GetIsolate();
+ Factory* factory = isolate->factory();
+ Handle<GlobalObject> global(native_context->global_object());
+ Handle<Object> holder = global;
+ char* name = const_cast<char*>(holder_expr);
+ char* period_pos = strchr(name, '.');
+ while (period_pos != NULL) {
+ Vector<const char> property(name, static_cast<int>(period_pos - name));
+ holder = GetProperty(isolate, holder,
+ factory->InternalizeUtf8String(property));
+ if (strcmp(".prototype", period_pos) == 0) {
+ Handle<JSFunction> function = Handle<JSFunction>::cast(holder);
+ return Handle<JSObject>(JSObject::cast(function->prototype()));
+ } else {
+ name = period_pos + 1;
+ period_pos = strchr(name, '.');
+ }
+ }
+
+ return Handle<JSObject>::cast(GetProperty(
+ isolate, holder, factory->InternalizeUtf8String(name)));
+}
+
+
static void InstallBuiltinFunctionId(Handle<JSObject> holder,
const char* function_name,
BuiltinFunctionId id) {
@@ -2122,6 +2201,25 @@ void Genesis::InstallBuiltinFunctionIds() {
}
+void Genesis::InstallExperimentalSIMDBuiltinFunctionIds() {
+ HandleScope scope(isolate());
+#define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
+ { \
+ Handle<JSObject> holder = ResolveBuiltinSIMDIdHolder( \
+ native_context(), #holder_expr); \
+ BuiltinFunctionId id = k##name; \
+ InstallBuiltinFunctionId(holder, #fun_name, id); \
+ }
+ EXPERIMENTAL_SIMD_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)
+#undef INSTALL_BUILTIN_ID
+ {
+ Handle<GlobalObject> global(native_context()->global_object());
+ InstallBuiltinFunctionId(global, "float32x4", kFloat32x4Constructor);
+ InstallBuiltinFunctionId(global, "int32x4", kInt32x4Constructor);
+ }
+}
+
+
// Do not forget to update macros.py with named constant
// of cache id.
#define JSFUNCTION_RESULT_CACHE_LIST(F) \
« no previous file with comments | « src/ast.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698