OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-stub-assembler.h" | 7 #include "src/code-stub-assembler.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 // ----------------------------------------------------------------------------- | 12 // ----------------------------------------------------------------------------- |
13 // ES6 section 22.2 TypedArray Objects | 13 // ES6 section 22.2 TypedArray Objects |
14 | 14 |
15 // ES6 section 22.2.3.1 get %TypedArray%.prototype.buffer | 15 // ES6 section 22.2.3.1 get %TypedArray%.prototype.buffer |
16 BUILTIN(TypedArrayPrototypeBuffer) { | 16 BUILTIN(TypedArrayPrototypeBuffer) { |
17 HandleScope scope(isolate); | 17 HandleScope scope(isolate); |
18 CHECK_RECEIVER(JSTypedArray, typed_array, "get TypedArray.prototype.buffer"); | 18 CHECK_RECEIVER(JSTypedArray, typed_array, "get TypedArray.prototype.buffer"); |
19 return *typed_array->GetBuffer(); | 19 return *typed_array->GetBuffer(); |
20 } | 20 } |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 void Generate_TypedArrayProtoypeGetter(compiler::CodeAssemblerState* state, | 24 void Generate_TypedArrayPrototypeGetter(compiler::CodeAssemblerState* state, |
25 const char* method_name, | 25 const char* method_name, |
26 int object_offset) { | 26 int object_offset) { |
27 typedef CodeStubAssembler::Label Label; | 27 typedef CodeStubAssembler::Label Label; |
28 typedef compiler::Node Node; | 28 typedef compiler::Node Node; |
29 CodeStubAssembler assembler(state); | 29 CodeStubAssembler assembler(state); |
30 | 30 |
31 Node* receiver = assembler.Parameter(0); | 31 Node* receiver = assembler.Parameter(0); |
32 Node* context = assembler.Parameter(3); | 32 Node* context = assembler.Parameter(3); |
33 | 33 |
34 // Check if the {receiver} is actually a JSTypedArray. | 34 // Check if the {receiver} is actually a JSTypedArray. |
35 Label if_receiverisincompatible(&assembler, Label::kDeferred); | 35 Label if_receiverisincompatible(&assembler, Label::kDeferred); |
36 assembler.GotoIf(assembler.TaggedIsSmi(receiver), &if_receiverisincompatible); | 36 assembler.GotoIf(assembler.TaggedIsSmi(receiver), &if_receiverisincompatible); |
(...skipping 27 matching lines...) Expand all Loading... |
64 receiver); | 64 receiver); |
65 assembler.Return(result); // Never reached. | 65 assembler.Return(result); // Never reached. |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 // ES6 section 22.2.3.2 get %TypedArray%.prototype.byteLength | 71 // ES6 section 22.2.3.2 get %TypedArray%.prototype.byteLength |
72 void Builtins::Generate_TypedArrayPrototypeByteLength( | 72 void Builtins::Generate_TypedArrayPrototypeByteLength( |
73 compiler::CodeAssemblerState* state) { | 73 compiler::CodeAssemblerState* state) { |
74 Generate_TypedArrayProtoypeGetter(state, | 74 Generate_TypedArrayPrototypeGetter(state, |
75 "get TypedArray.prototype.byteLength", | 75 "get TypedArray.prototype.byteLength", |
76 JSTypedArray::kByteLengthOffset); | 76 JSTypedArray::kByteLengthOffset); |
77 } | 77 } |
78 | 78 |
79 // ES6 section 22.2.3.3 get %TypedArray%.prototype.byteOffset | 79 // ES6 section 22.2.3.3 get %TypedArray%.prototype.byteOffset |
80 void Builtins::Generate_TypedArrayPrototypeByteOffset( | 80 void Builtins::Generate_TypedArrayPrototypeByteOffset( |
81 compiler::CodeAssemblerState* state) { | 81 compiler::CodeAssemblerState* state) { |
82 Generate_TypedArrayProtoypeGetter(state, | 82 Generate_TypedArrayPrototypeGetter(state, |
83 "get TypedArray.prototype.byteOffset", | 83 "get TypedArray.prototype.byteOffset", |
84 JSTypedArray::kByteOffsetOffset); | 84 JSTypedArray::kByteOffsetOffset); |
85 } | 85 } |
86 | 86 |
87 // ES6 section 22.2.3.18 get %TypedArray%.prototype.length | 87 // ES6 section 22.2.3.18 get %TypedArray%.prototype.length |
88 void Builtins::Generate_TypedArrayPrototypeLength( | 88 void Builtins::Generate_TypedArrayPrototypeLength( |
89 compiler::CodeAssemblerState* state) { | 89 compiler::CodeAssemblerState* state) { |
90 Generate_TypedArrayProtoypeGetter(state, "get TypedArray.prototype.length", | 90 Generate_TypedArrayPrototypeGetter(state, "get TypedArray.prototype.length", |
91 JSTypedArray::kLengthOffset); | 91 JSTypedArray::kLengthOffset); |
92 } | 92 } |
93 | 93 |
94 namespace { | 94 namespace { |
95 | 95 |
96 template <IterationKind kIterationKind> | 96 template <IterationKind kIterationKind> |
97 void Generate_TypedArrayPrototypeIterationMethod( | 97 void Generate_TypedArrayPrototypeIterationMethod( |
98 compiler::CodeAssemblerState* state, const char* method_name) { | 98 compiler::CodeAssemblerState* state, const char* method_name) { |
99 typedef compiler::Node Node; | 99 typedef compiler::Node Node; |
100 typedef CodeStubAssembler::Label Label; | 100 typedef CodeStubAssembler::Label Label; |
101 typedef CodeStubAssembler::Variable Variable; | 101 typedef CodeStubAssembler::Variable Variable; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 void Builtins::Generate_TypedArrayPrototypeKeys( | 164 void Builtins::Generate_TypedArrayPrototypeKeys( |
165 compiler::CodeAssemblerState* state) { | 165 compiler::CodeAssemblerState* state) { |
166 Generate_TypedArrayPrototypeIterationMethod<IterationKind::kKeys>( | 166 Generate_TypedArrayPrototypeIterationMethod<IterationKind::kKeys>( |
167 state, "%TypedArray%.prototype.keys()"); | 167 state, "%TypedArray%.prototype.keys()"); |
168 } | 168 } |
169 | 169 |
170 } // namespace internal | 170 } // namespace internal |
171 } // namespace v8 | 171 } // namespace v8 |
OLD | NEW |