| 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 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "src/compiler.h" | 37 #include "src/compiler.h" |
| 38 #include "src/scanner-character-streams.h" | 38 #include "src/scanner-character-streams.h" |
| 39 #include "tools/shell-utils.h" | 39 #include "tools/shell-utils.h" |
| 40 #include "src/parser.h" | 40 #include "src/parser.h" |
| 41 #include "src/preparse-data-format.h" | 41 #include "src/preparse-data-format.h" |
| 42 #include "src/preparse-data.h" | 42 #include "src/preparse-data.h" |
| 43 #include "src/preparser.h" | 43 #include "src/preparser.h" |
| 44 | 44 |
| 45 using namespace v8::internal; | 45 using namespace v8::internal; |
| 46 | 46 |
| 47 class StringResource8 : public v8::String::ExternalAsciiStringResource { |
| 48 public: |
| 49 StringResource8(const char* data, int length) |
| 50 : data_(data), length_(length) { } |
| 51 virtual size_t length() const { return length_; } |
| 52 virtual const char* data() const { return data_; } |
| 53 |
| 54 private: |
| 55 const char* data_; |
| 56 int length_; |
| 57 }; |
| 58 |
| 47 std::pair<TimeDelta, TimeDelta> RunBaselineParser( | 59 std::pair<TimeDelta, TimeDelta> RunBaselineParser( |
| 48 const char* fname, Encoding encoding, int repeat, v8::Isolate* isolate, | 60 const char* fname, Encoding encoding, int repeat, v8::Isolate* isolate, |
| 49 v8::Handle<v8::Context> context) { | 61 v8::Handle<v8::Context> context) { |
| 50 int length = 0; | 62 int length = 0; |
| 51 const byte* source = ReadFileAndRepeat(fname, &length, repeat); | 63 const byte* source = ReadFileAndRepeat(fname, &length, repeat); |
| 52 v8::Handle<v8::String> source_handle; | 64 v8::Handle<v8::String> source_handle; |
| 53 switch (encoding) { | 65 switch (encoding) { |
| 54 case UTF8: { | 66 case UTF8: { |
| 55 source_handle = v8::String::NewFromUtf8( | 67 source_handle = v8::String::NewFromUtf8( |
| 56 isolate, reinterpret_cast<const char*>(source)); | 68 isolate, reinterpret_cast<const char*>(source)); |
| 57 break; | 69 break; |
| 58 } | 70 } |
| 59 case UTF16: { | 71 case UTF16: { |
| 60 source_handle = v8::String::NewFromTwoByte( | 72 source_handle = v8::String::NewFromTwoByte( |
| 61 isolate, reinterpret_cast<const uint16_t*>(source), | 73 isolate, reinterpret_cast<const uint16_t*>(source), |
| 62 v8::String::kNormalString, length / 2); | 74 v8::String::kNormalString, length / 2); |
| 63 break; | 75 break; |
| 64 } | 76 } |
| 65 case LATIN1: { | 77 case LATIN1: { |
| 66 source_handle = v8::String::NewFromOneByte(isolate, source); | 78 StringResource8* string_resource = |
| 79 new StringResource8(reinterpret_cast<const char*>(source), length); |
| 80 source_handle = v8::String::NewExternal(isolate, string_resource); |
| 67 break; | 81 break; |
| 68 } | 82 } |
| 69 } | 83 } |
| 70 TimeDelta parse_time1, parse_time2; | 84 TimeDelta parse_time1, parse_time2; |
| 71 Handle<Script> script = Isolate::Current()->factory()->NewScript( | 85 Handle<Script> script = Isolate::Current()->factory()->NewScript( |
| 72 v8::Utils::OpenHandle(*source_handle)); | 86 v8::Utils::OpenHandle(*source_handle)); |
| 73 i::ScriptData* cached_data_impl = NULL; | 87 i::ScriptData* cached_data_impl = NULL; |
| 74 // First round of parsing (produce data to cache). | 88 // First round of parsing (produce data to cache). |
| 75 { | 89 { |
| 76 CompilationInfoWithZone info(script); | 90 CompilationInfoWithZone info(script); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (benchmark.empty()) benchmark = "Baseline"; | 162 if (benchmark.empty()) benchmark = "Baseline"; |
| 149 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(), | 163 printf("%s(FirstParseRunTime): %.f ms\n", benchmark.c_str(), |
| 150 first_parse_total); | 164 first_parse_total); |
| 151 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), | 165 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), |
| 152 second_parse_total); | 166 second_parse_total); |
| 153 } | 167 } |
| 154 } | 168 } |
| 155 v8::V8::Dispose(); | 169 v8::V8::Dispose(); |
| 156 return 0; | 170 return 0; |
| 157 } | 171 } |
| OLD | NEW |