| 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 24 matching lines...) Expand all Loading... |
| 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 // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair. | 46 // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair. |
| 46 CompilationInfoWithZone info(GetFunction(isolate(), "STRING_LENGTH_STUB")); | 47 ParseInfo parse_info(&zone, GetFunction(isolate(), "STRING_LENGTH_STUB")); |
| 48 CompilationInfo info(&parse_info); |
| 47 info.SetStub(this); | 49 info.SetStub(this); |
| 48 // Run a "mini pipeline", extracted from compiler.cc. | 50 // Run a "mini pipeline", extracted from compiler.cc. |
| 49 CHECK(Parser::ParseStatic(info.parse_info())); | 51 CHECK(Parser::ParseStatic(info.parse_info())); |
| 50 CHECK(Compiler::Analyze(info.parse_info())); | 52 CHECK(Compiler::Analyze(info.parse_info())); |
| 51 return Pipeline(&info).GenerateCode(); | 53 return Pipeline(&info).GenerateCode(); |
| 52 } | 54 } |
| 53 | 55 |
| 54 Major MajorKey() const OVERRIDE { return StringLength; }; | 56 Major MajorKey() const OVERRIDE { return StringLength; }; |
| 55 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } | 57 Code::Kind GetCodeKind() const OVERRIDE { return Code::HANDLER; } |
| 56 InlineCacheState GetICState() const OVERRIDE { return MONOMORPHIC; } | 58 InlineCacheState GetICState() const OVERRIDE { return MONOMORPHIC; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Actuall call through to the stub, verifying its result. | 97 // Actuall call through to the stub, verifying its result. |
| 96 const char* testString = "Und das Lamm schrie HURZ!"; | 98 const char* testString = "Und das Lamm schrie HURZ!"; |
| 97 Handle<JSReceiver> receiverArg = | 99 Handle<JSReceiver> receiverArg = |
| 98 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); | 100 Object::ToObject(isolate, ft.Val(testString)).ToHandleChecked(); |
| 99 Handle<String> nameArg = ft.Val("length"); | 101 Handle<String> nameArg = ft.Val("length"); |
| 100 Handle<Object> result = ft.Call(receiverArg, nameArg).ToHandleChecked(); | 102 Handle<Object> result = ft.Call(receiverArg, nameArg).ToHandleChecked(); |
| 101 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); | 103 CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value()); |
| 102 } | 104 } |
| 103 | 105 |
| 104 #endif // V8_TURBOFAN_TARGET | 106 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |