| Index: tools/lexer-shell.cc
|
| diff --git a/src/lexer/lexer-shell.cc b/tools/lexer-shell.cc
|
| similarity index 67%
|
| copy from src/lexer/lexer-shell.cc
|
| copy to tools/lexer-shell.cc
|
| index 16c4db7ed1c9b432392ee629bc78fbb47acd73bb..0d256f83d7e34869ead3b4862d57c38d45c2382c 100644
|
| --- a/src/lexer/lexer-shell.cc
|
| +++ b/tools/lexer-shell.cc
|
| @@ -31,6 +31,7 @@
|
| #include <stdio.h>
|
| #include <stdlib.h>
|
| #include <string>
|
| +#include <vector>
|
| #include "v8.h"
|
|
|
| #include "api.h"
|
| @@ -44,8 +45,6 @@
|
| #include "string-stream.h"
|
| #include "scanner.h"
|
|
|
| -#include "experimental-scanner.h"
|
| -#include "lexer.h"
|
|
|
| using namespace v8::internal;
|
|
|
| @@ -75,6 +74,7 @@ const byte* ReadFile(const char* name, Isolate* isolate, int* size) {
|
| return chars;
|
| }
|
|
|
| +
|
| class BaselineScanner {
|
| public:
|
| BaselineScanner(const char* fname,
|
| @@ -173,27 +173,6 @@ TimeDelta RunBaselineScanner(const char* fname,
|
| }
|
|
|
|
|
| -TimeDelta RunExperimentalScanner(const char* fname,
|
| - Isolate* isolate,
|
| - Encoding encoding,
|
| - bool dump_tokens,
|
| - std::vector<TokenWithLocation>* tokens) {
|
| - ElapsedTimer timer;
|
| - timer.Start();
|
| - ExperimentalScanner scanner(fname, true, isolate);
|
| - Token::Value token;
|
| - do {
|
| - token = scanner.Next();
|
| - ExperimentalScanner::Location location = scanner.location();
|
| - if (dump_tokens) {
|
| - tokens->push_back(
|
| - TokenWithLocation(token, location.beg_pos, location.end_pos));
|
| - }
|
| - } while (token != Token::EOS);
|
| - return timer.Elapsed();
|
| -}
|
| -
|
| -
|
| void PrintTokens(const char* name,
|
| const std::vector<TokenWithLocation>& tokens) {
|
| printf("No of tokens: %d\n",
|
| @@ -205,55 +184,24 @@ void PrintTokens(const char* name,
|
| }
|
|
|
|
|
| -std::pair<TimeDelta, TimeDelta> ProcessFile(
|
| +TimeDelta ProcessFile(
|
| const char* fname,
|
| Encoding encoding,
|
| Isolate* isolate,
|
| - bool run_baseline,
|
| - bool run_experimental,
|
| - bool print_tokens,
|
| - bool check_tokens) {
|
| + bool print_tokens) {
|
| if (print_tokens) {
|
| printf("Processing file %s\n", fname);
|
| }
|
| HandleScope handle_scope(isolate);
|
| - std::vector<TokenWithLocation> baseline_tokens, experimental_tokens;
|
| - TimeDelta baseline_time, experimental_time;
|
| - if (run_baseline) {
|
| - baseline_time = RunBaselineScanner(
|
| - fname, isolate, encoding, print_tokens || check_tokens,
|
| - &baseline_tokens);
|
| - }
|
| - if (run_experimental) {
|
| - experimental_time = RunExperimentalScanner(
|
| - fname, isolate, encoding, print_tokens || check_tokens,
|
| - &experimental_tokens);
|
| - }
|
| - if (print_tokens && !run_experimental) {
|
| + std::vector<TokenWithLocation> baseline_tokens;
|
| + TimeDelta baseline_time;
|
| + baseline_time = RunBaselineScanner(
|
| + fname, isolate, encoding, print_tokens,
|
| + &baseline_tokens);
|
| + if (print_tokens) {
|
| PrintTokens("Baseline", baseline_tokens);
|
| }
|
| - if (print_tokens && !run_baseline) {
|
| - PrintTokens("Experimental", experimental_tokens);
|
| - }
|
| - if ((print_tokens || check_tokens) && run_baseline && run_experimental) {
|
| - if (print_tokens) {
|
| - printf("No of tokens in Baseline: %d\n",
|
| - static_cast<int>(baseline_tokens.size()));
|
| - printf("No of tokens in Experimental: %d\n",
|
| - static_cast<int>(experimental_tokens.size()));
|
| - printf("Baseline and Experimental:\n");
|
| - }
|
| - for (size_t i = 0; i < experimental_tokens.size(); ++i) {
|
| - if (print_tokens) experimental_tokens[i].Print("=>");
|
| - if (experimental_tokens[i] != baseline_tokens[i]) {
|
| - printf("MISMATCH:\n");
|
| - baseline_tokens[i].Print("Expected: ");
|
| - experimental_tokens[i].Print("Actual: ");
|
| - exit(1);
|
| - }
|
| - }
|
| - }
|
| - return std::make_pair(baseline_time, experimental_time);
|
| + return baseline_time;
|
| }
|
|
|
|
|
| @@ -262,9 +210,6 @@ int main(int argc, char* argv[]) {
|
| v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
|
| Encoding encoding = LATIN1;
|
| bool print_tokens = false;
|
| - bool run_baseline = true;
|
| - bool run_experimental = true;
|
| - bool check_tokens = true;
|
| std::vector<std::string> fnames;
|
| std::string benchmark;
|
| for (int i = 0; i < argc; ++i) {
|
| @@ -276,12 +221,6 @@ int main(int argc, char* argv[]) {
|
| encoding = UTF16;
|
| } else if (strcmp(argv[i], "--print-tokens") == 0) {
|
| print_tokens = true;
|
| - } else if (strcmp(argv[i], "--no-baseline") == 0) {
|
| - run_baseline = false;
|
| - } else if (strcmp(argv[i], "--no-experimental") == 0) {
|
| - run_experimental = false;
|
| - } else if (strcmp(argv[i], "--no-check") == 0) {
|
| - check_tokens = false;
|
| } else if (strncmp(argv[i], "--benchmark=", 12) == 0) {
|
| benchmark = std::string(argv[i]).substr(12);
|
| } else if (i > 0 && argv[i][0] != '-') {
|
| @@ -297,24 +236,14 @@ int main(int argc, char* argv[]) {
|
| {
|
| v8::Context::Scope scope(context);
|
| Isolate* isolate = Isolate::Current();
|
| - double baseline_total = 0, experimental_total = 0;
|
| + double baseline_total = 0;
|
| for (size_t i = 0; i < fnames.size(); i++) {
|
| - std::pair<TimeDelta, TimeDelta> times;
|
| - check_tokens = check_tokens && run_baseline && run_experimental;
|
| - times = ProcessFile(fnames[i].c_str(), encoding, isolate, run_baseline,
|
| - run_experimental, print_tokens, check_tokens);
|
| - baseline_total += times.first.InMillisecondsF();
|
| - experimental_total += times.second.InMillisecondsF();
|
| - }
|
| - if (run_baseline) {
|
| - printf("Baseline%s(RunTime): %.f ms\n", benchmark.c_str(),
|
| - baseline_total);
|
| - }
|
| - if (run_experimental) {
|
| - if (benchmark.empty()) benchmark = "Experimental";
|
| - printf("%s(RunTime): %.f ms\n", benchmark.c_str(),
|
| - experimental_total);
|
| + TimeDelta time;
|
| + time = ProcessFile(fnames[i].c_str(), encoding, isolate, print_tokens);
|
| + baseline_total += time.InMillisecondsF();
|
| }
|
| + if (benchmark.empty()) benchmark = "Baseline";
|
| + printf("%s(RunTime): %.f ms\n", benchmark.c_str(), baseline_total);
|
| }
|
| }
|
| v8::V8::Dispose();
|
|
|