| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 // | |
| 28 // Tests of profiles generator and utilities. | |
| 29 | 27 |
| 30 #ifndef V8_TEST_CCTEST_PROFILER_EXTENSION_H_ | 28 #ifndef V8_TYPING_ASM_H_ |
| 31 #define V8_TEST_CCTEST_PROFILER_EXTENSION_H_ | 29 #define V8_TYPING_ASM_H_ |
| 32 | 30 |
| 33 #include "include/v8-profiler.h" | 31 #include "v8.h" |
| 32 |
| 33 #include "allocation.h" |
| 34 #include "ast.h" |
| 35 #include "compiler.h" |
| 36 #include "scopes.h" |
| 37 #include "types.h" |
| 38 #include "zone.h" |
| 34 | 39 |
| 35 namespace v8 { | 40 namespace v8 { |
| 36 namespace internal { | 41 namespace internal { |
| 37 | 42 |
| 38 class ProfilerExtension : public v8::Extension { | 43 |
| 44 class AsmTyper: public AstVisitor { |
| 39 public: | 45 public: |
| 40 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } | 46 static bool Run(CompilationInfo* info); |
| 41 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 47 |
| 42 v8::Isolate* isolate, | 48 void* operator new(size_t size, Zone* zone) { |
| 43 v8::Handle<v8::String> name); | 49 return zone->New(static_cast<int>(size)); |
| 44 static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); | 50 } |
| 45 static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args); | 51 void operator delete(void* pointer, Zone* zone) { } |
| 46 static v8::CpuProfile* last_profile; | 52 void operator delete(void* pointer) { } |
| 53 |
| 54 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 55 |
| 47 private: | 56 private: |
| 48 static const char* kSource; | 57 explicit AsmTyper(CompilationInfo* info); |
| 58 |
| 59 CompilationInfo* info_; |
| 60 Handle<Type> expected_type_; |
| 61 Handle<Type> computed_type_; |
| 62 Handle<Type> return_type_; |
| 63 bool valid_; |
| 64 |
| 65 Zone* zone() const { return info_->zone(); } |
| 66 |
| 67 Handle<Type> handle_type(Type* type) { return Handle<Type>(type, isolate_); } |
| 68 Handle<Type> handle_type(Handle<Type> type) { return type; } |
| 69 |
| 70 void VisitDeclarations(ZoneList<Declaration*>* d); |
| 71 void VisitStatements(ZoneList<Statement*>* s); |
| 72 |
| 73 void VisitExpressionAnnotation(Expression* e); |
| 74 void VisitFunctionAnnotation(FunctionLiteral* f); |
| 75 void VisitAsmModule(FunctionLiteral* f); |
| 76 |
| 77 Handle<Type> StdlibType(); |
| 78 |
| 79 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 80 AST_NODE_LIST(DECLARE_VISIT) |
| 81 #undef DECLARE_VISIT |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(AsmTyper); |
| 49 }; | 84 }; |
| 50 | 85 |
| 51 | |
| 52 } } // namespace v8::internal | 86 } } // namespace v8::internal |
| 53 | 87 |
| 54 #endif | 88 #endif // V8_TYPING_ASM_H_ |
| OLD | NEW |