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

Side by Side Diff: src/harmony-simd.js

Issue 1219943002: Expose SIMD.Float32x4 type to Javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: samevalue.js tweak. Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var $float32x4ToString;
6
7 (function(global, utils) {
8
9 "use strict";
10
11 %CheckIsBootstrapping();
12
13 // -------------------------------------------------------------------
14 // Imports
15
16 var GlobalSIMD = global.SIMD;
17 var GlobalFloat32x4 = GlobalSIMD.Float32x4;
18
19 //-------------------------------------------------------------------
20
21 function Float32x4Constructor(x, y, z, w) {
22 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Float32x4");
23 if (!IS_NUMBER(x) || !IS_NUMBER(y) || !IS_NUMBER(z) || !IS_NUMBER(w)) {
24 throw MakeTypeError(kInvalidArgument);
25 }
26 return %CreateFloat32x4(x, y, z, w);
27 }
28
29 function Float32x4Splat(s) {
30 return %CreateFloat32x4(s, s, s, s);
31 }
32
33 function Float32x4CheckJS(a) {
34 return %Float32x4Check(a);
35 }
36
37 function Float32x4ToString() {
38 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) {
39 throw MakeTypeError(kIncompatibleMethodReceiver,
40 "Float32x4.prototype.toString", this);
41 }
42 var value = %_ValueOf(this);
43 var w = GlobalFloat32x4.extractLane(value, 0),
44 x = GlobalFloat32x4.extractLane(value, 1),
45 y = GlobalFloat32x4.extractLane(value, 2),
46 z = GlobalFloat32x4.extractLane(value, 3);
47 return "Float32x4(" + w + ", " + x + ", " + y + ", " + z + ")";
48 }
49
50 function Float32x4ValueOf() {
51 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) {
52 throw MakeTypeError(kIncompatibleMethodReceiver,
53 "Float32x4.prototype.valueOf", this);
54 }
55 return %_ValueOf(this);
56 }
57
58 //-------------------------------------------------------------------
59
60 function Float32x4ExtractLaneJS(value, lane) {
61 return %Float32x4ExtractLane(value, lane);
62 }
63
64 // -------------------------------------------------------------------
65
66 %AddNamedProperty(GlobalSIMD, symbolToStringTag, 'SIMD', READ_ONLY | DONT_ENUM);
67 %AddNamedProperty(GlobalSIMD, 'float32x4', GlobalFloat32x4, DONT_ENUM);
68
69 %SetCode(GlobalFloat32x4, Float32x4Constructor);
70 %FunctionSetPrototype(GlobalFloat32x4, {});
71 %AddNamedProperty(
72 GlobalFloat32x4.prototype, 'constructor', GlobalFloat32x4, DONT_ENUM);
73 %AddNamedProperty(
74 GlobalFloat32x4, symbolToStringTag, 'Float32x4', DONT_ENUM | READ_ONLY);
75
76 utils.InstallFunctions(GlobalFloat32x4.prototype, DONT_ENUM, [
77 'valueOf', Float32x4ValueOf,
78 'toString', Float32x4ToString,
79 ]);
80
81 utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [
82 'splat', Float32x4Splat,
83 'check', Float32x4CheckJS,
84 'extractLane', Float32x4ExtractLaneJS,
85 ]);
86
87 $float32x4ToString = Float32x4ToString;
88
89 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698