OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 return function; | 30 return function; |
31 } | 31 } |
32 | 32 |
33 | 33 |
34 class StringLengthStubTF : public CodeStub { | 34 class StringLengthStubTF : public CodeStub { |
35 public: | 35 public: |
36 explicit StringLengthStubTF(Isolate* isolate) : CodeStub(isolate) {} | 36 explicit StringLengthStubTF(Isolate* isolate) : CodeStub(isolate) {} |
37 | 37 |
38 StringLengthStubTF(uint32_t key, Isolate* isolate) : CodeStub(key, isolate) {} | 38 StringLengthStubTF(uint32_t key, Isolate* isolate) : CodeStub(key, isolate) {} |
39 | 39 |
40 CallInterfaceDescriptor GetCallInterfaceDescriptor() OVERRIDE { | 40 CallInterfaceDescriptor GetCallInterfaceDescriptor() override { |
41 return LoadDescriptor(isolate()); | 41 return LoadDescriptor(isolate()); |
42 }; | 42 }; |
43 | 43 |
44 Handle<Code> GenerateCode() OVERRIDE { | 44 Handle<Code> GenerateCode() override { |
45 Zone zone; | 45 Zone zone; |
46 // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair. | 46 // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair. |
47 ParseInfo parse_info(&zone, GetFunction(isolate(), "STRING_LENGTH_STUB")); | 47 ParseInfo parse_info(&zone, GetFunction(isolate(), "STRING_LENGTH_STUB")); |
48 CompilationInfo info(&parse_info); | 48 CompilationInfo info(&parse_info); |
49 info.SetStub(this); | 49 info.SetStub(this); |
50 // Run a "mini pipeline", extracted from compiler.cc. | 50 // Run a "mini pipeline", extracted from compiler.cc. |
51 CHECK(Parser::ParseStatic(info.parse_info())); | 51 CHECK(Parser::ParseStatic(info.parse_info())); |
52 CHECK(Compiler::Analyze(info.parse_info())); | 52 CHECK(Compiler::Analyze(info.parse_info())); |
53 return Pipeline(&info).GenerateCode(); | 53 return Pipeline(&info).GenerateCode(); |
54 } | 54 } |
55 | 55 |
56 Major MajorKey() const OVERRIDE { return StringLength; }; | 56 Major MajorKey() const override { return StringLength; }; |
57 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } | 57 Code::Kind GetCodeKind() const override { return Code::HANDLER; } |
58 InlineCacheState GetICState() const OVERRIDE { return MONOMORPHIC; } | 58 InlineCacheState GetICState() const override { return MONOMORPHIC; } |
59 ExtraICState GetExtraICState() const OVERRIDE { return Code::LOAD_IC; } | 59 ExtraICState GetExtraICState() const override { return Code::LOAD_IC; } |
60 Code::StubType GetStubType() const OVERRIDE { return Code::FAST; } | 60 Code::StubType GetStubType() const override { return Code::FAST; } |
61 | 61 |
62 private: | 62 private: |
63 DISALLOW_COPY_AND_ASSIGN(StringLengthStubTF); | 63 DISALLOW_COPY_AND_ASSIGN(StringLengthStubTF); |
64 }; | 64 }; |
65 | 65 |
66 | 66 |
67 TEST(RunStringLengthStubTF) { | 67 TEST(RunStringLengthStubTF) { |
68 HandleAndZoneScope scope; | 68 HandleAndZoneScope scope; |
69 Isolate* isolate = scope.main_isolate(); | 69 Isolate* isolate = scope.main_isolate(); |
70 Zone* zone = scope.main_zone(); | 70 Zone* zone = scope.main_zone(); |
(...skipping 26 matching lines...) Expand all Loading... |
97 // Actuall call through to the stub, verifying its result. | 97 // Actuall call through to the stub, verifying its result. |
98 const char* testString = "Und das Lamm schrie HURZ!"; | 98 const char* testString = "Und das Lamm schrie HURZ!"; |
99 Handle<JSReceiver> receiverArg = | 99 Handle<JSReceiver> receiverArg = |
100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); | 100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); |
101 Handle<String> nameArg = ft.Val("length"); | 101 Handle<String> nameArg = ft.Val("length"); |
102 Handle<Object> result = ft.Call(receiverArg, nameArg).ToHandleChecked(); | 102 Handle<Object> result = ft.Call(receiverArg, nameArg).ToHandleChecked(); |
103 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); | 103 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); |
104 } | 104 } |
105 | 105 |
106 #endif // V8_TURBOFAN_TARGET | 106 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |