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

Side by Side Diff: test/cctest/compiler/test-changes-lowering.cc

Issue 637873002: The empty husk of a JSFunction is useful to us. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 <limits> 5 #include <limits>
6 6
7 #include "src/compiler/change-lowering.h" 7 #include "src/compiler/change-lowering.h"
8 #include "src/compiler/control-builders.h" 8 #include "src/compiler/control-builders.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
11 #include "src/compiler/node-properties-inl.h" 11 #include "src/compiler/node-properties-inl.h"
12 #include "src/compiler/pipeline.h" 12 #include "src/compiler/pipeline.h"
13 #include "src/compiler/typer.h" 13 #include "src/compiler/typer.h"
14 #include "src/compiler/verifier.h" 14 #include "src/compiler/verifier.h"
15 #include "src/execution.h" 15 #include "src/execution.h"
16 #include "src/globals.h" 16 #include "src/globals.h"
17 #include "src/parser.h" 17 #include "src/parser.h"
18 #include "src/rewriter.h" 18 #include "src/rewriter.h"
19 #include "src/scopes.h" 19 #include "src/scopes.h"
20 #include "test/cctest/cctest.h" 20 #include "test/cctest/cctest.h"
21 #include "test/cctest/compiler/codegen-tester.h" 21 #include "test/cctest/compiler/codegen-tester.h"
22 #include "test/cctest/compiler/function-tester.h"
22 #include "test/cctest/compiler/graph-builder-tester.h" 23 #include "test/cctest/compiler/graph-builder-tester.h"
23 #include "test/cctest/compiler/value-helper.h" 24 #include "test/cctest/compiler/value-helper.h"
24 25
25 using namespace v8::internal; 26 using namespace v8::internal;
26 using namespace v8::internal::compiler; 27 using namespace v8::internal::compiler;
27 28
28 template <typename ReturnType> 29 template <typename ReturnType>
29 class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { 30 class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
30 public: 31 public:
31 explicit ChangesLoweringTester(MachineType p0 = kMachNone) 32 explicit ChangesLoweringTester(MachineType p0 = kMachNone)
32 : GraphBuilderTester<ReturnType>(p0), 33 : GraphBuilderTester<ReturnType>(p0),
33 typer(this->zone()), 34 typer(this->zone()),
34 javascript(this->zone()), 35 javascript(this->zone()),
35 jsgraph(this->graph(), this->common(), &javascript, &typer, 36 jsgraph(this->graph(), this->common(), &javascript, &typer,
36 this->machine()), 37 this->machine()),
37 function(Handle<JSFunction>::null()) {} 38 function(Handle<JSFunction>::null()) {}
38 39
39 Typer typer; 40 Typer typer;
40 JSOperatorBuilder javascript; 41 JSOperatorBuilder javascript;
41 JSGraph jsgraph; 42 JSGraph jsgraph;
42 Handle<JSFunction> function; 43 Handle<JSFunction> function;
43 44
44 Node* start() { return this->graph()->start(); } 45 Node* start() { return this->graph()->start(); }
45 46
46 template <typename T> 47 template <typename T>
47 T* CallWithPotentialGC() { 48 T* CallWithPotentialGC() {
48 // TODO(titzer): we need to wrap the code in a JSFunction and call it via 49 // TODO(titzer): we wrap the code in a JSFunction here to reuse the
49 // Execution::Call() so that the GC knows about the frame, can walk it, 50 // JSEntryStub; that could be done with a special prologue or other stub.
50 // relocate the code object if necessary, etc.
51 // This is pretty ugly and at the least should be moved up to helpers.
52 if (function.is_null()) { 51 if (function.is_null()) {
53 function = 52 function = FunctionTester::ForMachineGraph(this->graph());
54 v8::Utils::OpenHandle(*v8::Handle<v8::Function>::Cast(CompileRun(
55 "(function() { 'use strict'; return 2.7123; })")));
56 CompilationInfoWithZone info(function);
57 CHECK(Parser::Parse(&info));
58 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
59 CHECK(Rewriter::Rewrite(&info));
60 CHECK(Scope::Analyze(&info));
61 CHECK_NE(NULL, info.scope());
62 Handle<ScopeInfo> scope_info =
63 ScopeInfo::Create(info.scope(), info.zone());
64 info.shared_info()->set_scope_info(*scope_info);
65 Pipeline pipeline(&info);
66 Linkage linkage(&info);
67 Handle<Code> code =
68 pipeline.GenerateCodeForMachineGraph(&linkage, this->graph());
69 CHECK(!code.is_null());
70 function->ReplaceCode(*code);
71 } 53 }
72 Handle<Object>* args = NULL; 54 Handle<Object>* args = NULL;
73 MaybeHandle<Object> result = 55 MaybeHandle<Object> result =
74 Execution::Call(this->isolate(), function, factory()->undefined_value(), 56 Execution::Call(this->isolate(), function, factory()->undefined_value(),
75 0, args, false); 57 0, args, false);
76 return T::cast(*result.ToHandleChecked()); 58 return T::cast(*result.ToHandleChecked());
77 } 59 }
78 60
79 void StoreFloat64(Node* node, double* ptr) { 61 void StoreFloat64(Node* node, double* ptr) {
80 Node* ptr_node = this->PointerConstant(ptr); 62 Node* ptr_node = this->PointerConstant(ptr);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 386
405 input = *i; 387 input = *i;
406 Object* result = t.CallWithPotentialGC<Object>(); 388 Object* result = t.CallWithPotentialGC<Object>();
407 t.CheckNumber(input, result); 389 t.CheckNumber(input, result);
408 } 390 }
409 } 391 }
410 } 392 }
411 } 393 }
412 394
413 #endif // V8_TURBOFAN_BACKEND 395 #endif // V8_TURBOFAN_BACKEND
OLDNEW
« test/cctest/compiler/function-tester.h ('K') | « test/cctest/compiler/function-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698