1 // Copyright 2017 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 #include "src/builtins/builtins-utils-gen.h"
6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h"
8
9 namespace v8 {
10 namespace internal {
11
12 // -----------------------------------------------------------------------------
13 // ES6 #sec-symbol-objects
14 // ES ##sec-symbol.prototype.description
TF_BUILTIN(SymbolPrototypeDescriptionGetter,CodeStubAssembler)15 TF_BUILTIN(SymbolPrototypeDescriptionGetter, CodeStubAssembler) {
16 Node* context = Parameter(Descriptor::kContext);
17 Node* receiver = Parameter(Descriptor::kReceiver);
18
19 Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
20 "Symbol.prototype.description");
21 Node* result = LoadObjectField(value, Symbol::kNameOffset);
22 Return(result);
23 }
24
25 // ES6 #sec-symbol.prototype-@@toprimitive
TF_BUILTIN(SymbolPrototypeToPrimitive,CodeStubAssembler)26 TF_BUILTIN(SymbolPrototypeToPrimitive, CodeStubAssembler) {
27 Node* context = Parameter(Descriptor::kContext);
28 Node* receiver = Parameter(Descriptor::kReceiver);
29
30 Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
31 "Symbol.prototype [ @@toPrimitive ]");
32 Return(result);
33 }
34
35 // ES6 #sec-symbol.prototype.tostring
TF_BUILTIN(SymbolPrototypeToString,CodeStubAssembler)36 TF_BUILTIN(SymbolPrototypeToString, CodeStubAssembler) {
37 Node* context = Parameter(Descriptor::kContext);
38 Node* receiver = Parameter(Descriptor::kReceiver);
39
40 Node* value = ToThisValue(context, receiver, PrimitiveType::kSymbol,
41 "Symbol.prototype.toString");
42 Node* result = CallRuntime(Runtime::kSymbolDescriptiveString, context, value);
43 Return(result);
44 }
45
46 // ES6 #sec-symbol.prototype.valueof
TF_BUILTIN(SymbolPrototypeValueOf,CodeStubAssembler)47 TF_BUILTIN(SymbolPrototypeValueOf, CodeStubAssembler) {
48 Node* context = Parameter(Descriptor::kContext);
49 Node* receiver = Parameter(Descriptor::kReceiver);
50
51 Node* result = ToThisValue(context, receiver, PrimitiveType::kSymbol,
52 "Symbol.prototype.valueOf");
53 Return(result);
54 }
55
56 } // namespace internal
57 } // namespace v8
58