| OLD | NEW | 
|    1 // Copyright 2014 the V8 project authors. All rights reserved. |    1 // Copyright 2014 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  |   27  | 
 |   28 // TODO(mythria): Remove this after this flag is turned on globally | 
 |   29 #define V8_IMMINENT_DEPRECATION_WARNINGS | 
 |   30  | 
|   28 #include "test/cctest/trace-extension.h" |   31 #include "test/cctest/trace-extension.h" | 
|   29  |   32  | 
|   30 #include "src/sampler.h" |   33 #include "src/sampler.h" | 
|   31 #include "src/vm-state-inl.h" |   34 #include "src/vm-state-inl.h" | 
|   32 #include "test/cctest/cctest.h" |   35 #include "test/cctest/cctest.h" | 
|   33  |   36  | 
|   34 namespace v8 { |   37 namespace v8 { | 
|   35 namespace internal { |   38 namespace internal { | 
|   36  |   39  | 
|   37 const char* TraceExtension::kSource = |   40 const char* TraceExtension::kSource = | 
|   38     "native function trace();" |   41     "native function trace();" | 
|   39     "native function js_trace();" |   42     "native function js_trace();" | 
|   40     "native function js_entry_sp();" |   43     "native function js_entry_sp();" | 
|   41     "native function js_entry_sp_level2();"; |   44     "native function js_entry_sp_level2();"; | 
|   42  |   45  | 
|   43  |   46  | 
|   44 v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate( |   47 v8::Local<v8::FunctionTemplate> TraceExtension::GetNativeFunctionTemplate( | 
|   45     v8::Isolate* isolate, v8::Handle<v8::String> name) { |   48     v8::Isolate* isolate, v8::Local<v8::String> name) { | 
|   46   if (name->Equals(v8::String::NewFromUtf8(isolate, "trace"))) { |   49   v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 
 |   50   if (name->Equals(context, v8::String::NewFromUtf8(isolate, "trace", | 
 |   51                                                     v8::NewStringType::kNormal) | 
 |   52                                 .ToLocalChecked()) | 
 |   53           .FromJust()) { | 
|   47     return v8::FunctionTemplate::New(isolate, TraceExtension::Trace); |   54     return v8::FunctionTemplate::New(isolate, TraceExtension::Trace); | 
|   48   } else if (name->Equals(v8::String::NewFromUtf8(isolate, "js_trace"))) { |   55   } else if (name->Equals(context, | 
 |   56                           v8::String::NewFromUtf8(isolate, "js_trace", | 
 |   57                                                   v8::NewStringType::kNormal) | 
 |   58                               .ToLocalChecked()) | 
 |   59                  .FromJust()) { | 
|   49     return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace); |   60     return v8::FunctionTemplate::New(isolate, TraceExtension::JSTrace); | 
|   50   } else if (name->Equals(v8::String::NewFromUtf8(isolate, "js_entry_sp"))) { |   61   } else if (name->Equals(context, | 
 |   62                           v8::String::NewFromUtf8(isolate, "js_entry_sp", | 
 |   63                                                   v8::NewStringType::kNormal) | 
 |   64                               .ToLocalChecked()) | 
 |   65                  .FromJust()) { | 
|   51     return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP); |   66     return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySP); | 
|   52   } else if (name->Equals(v8::String::NewFromUtf8(isolate, |   67   } else if (name->Equals(context, | 
|   53                                                   "js_entry_sp_level2"))) { |   68                           v8::String::NewFromUtf8(isolate, "js_entry_sp_level2", | 
 |   69                                                   v8::NewStringType::kNormal) | 
 |   70                               .ToLocalChecked()) | 
 |   71                  .FromJust()) { | 
|   54     return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2); |   72     return v8::FunctionTemplate::New(isolate, TraceExtension::JSEntrySPLevel2); | 
|   55   } else { |   73   } else { | 
|   56     CHECK(false); |   74     CHECK(false); | 
|   57     return v8::Handle<v8::FunctionTemplate>(); |   75     return v8::Local<v8::FunctionTemplate>(); | 
|   58   } |   76   } | 
|   59 } |   77 } | 
|   60  |   78  | 
|   61  |   79  | 
|   62 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { |   80 Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& args) { | 
|   63   // Convert frame pointer from encoding as smis in the arguments to a pointer. |   81   // Convert frame pointer from encoding as smis in the arguments to a pointer. | 
|   64   CHECK_EQ(2, args.Length());  // Ignore second argument on 32-bit platform. |   82   CHECK_EQ(2, args.Length());  // Ignore second argument on 32-bit platform. | 
|   65 #if defined(V8_HOST_ARCH_32_BIT) |   83 #if defined(V8_HOST_ARCH_32_BIT) | 
|   66   Address fp = *reinterpret_cast<Address*>(*args[0]); |   84   Address fp = *reinterpret_cast<Address*>(*args[0]); | 
|   67 #elif defined(V8_HOST_ARCH_64_BIT) |   85 #elif defined(V8_HOST_ARCH_64_BIT) | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  146   v8::HandleScope scope(args.GetIsolate()); |  164   v8::HandleScope scope(args.GetIsolate()); | 
|  147   const Address js_entry_sp = GetJsEntrySp(); |  165   const Address js_entry_sp = GetJsEntrySp(); | 
|  148   CHECK(js_entry_sp); |  166   CHECK(js_entry_sp); | 
|  149   CompileRun("js_entry_sp();"); |  167   CompileRun("js_entry_sp();"); | 
|  150   CHECK_EQ(js_entry_sp, GetJsEntrySp()); |  168   CHECK_EQ(js_entry_sp, GetJsEntrySp()); | 
|  151 } |  169 } | 
|  152  |  170  | 
|  153  |  171  | 
|  154 }  // namespace internal |  172 }  // namespace internal | 
|  155 }  // namespace v8 |  173 }  // namespace v8 | 
| OLD | NEW |