| 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 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 scanner_ = new Scanner(unicode_cache_); | 97 scanner_ = new Scanner(unicode_cache_); |
| 98 switch (encoding) { | 98 switch (encoding) { |
| 99 case UTF8: | 99 case UTF8: |
| 100 stream_ = new Utf8ToUtf16CharacterStream(source_, length); | 100 stream_ = new Utf8ToUtf16CharacterStream(source_, length); |
| 101 break; | 101 break; |
| 102 case UTF16: { | 102 case UTF16: { |
| 103 Handle<String> result = isolate->factory()->NewStringFromTwoByte( | 103 Handle<String> result = isolate->factory()->NewStringFromTwoByte( |
| 104 Vector<const uint16_t>( | 104 Vector<const uint16_t>( |
| 105 reinterpret_cast<const uint16_t*>(source_), | 105 reinterpret_cast<const uint16_t*>(source_), |
| 106 length / 2)); | 106 length / 2)); |
| 107 CHECK_NOT_EMPTY_HANDLE(isolate, result); |
| 107 stream_ = | 108 stream_ = |
| 108 new GenericStringUtf16CharacterStream(result, 0, result->length()); | 109 new GenericStringUtf16CharacterStream(result, 0, result->length()); |
| 109 break; | 110 break; |
| 110 } | 111 } |
| 111 case LATIN1: { | 112 case LATIN1: { |
| 112 Handle<String> result = isolate->factory()->NewStringFromOneByte( | 113 Handle<String> result = isolate->factory()->NewStringFromOneByte( |
| 113 Vector<const uint8_t>(source_, length)); | 114 Vector<const uint8_t>(source_, length)); |
| 115 CHECK_NOT_EMPTY_HANDLE(isolate, result); |
| 114 stream_ = | 116 stream_ = |
| 115 new GenericStringUtf16CharacterStream(result, 0, result->length()); | 117 new GenericStringUtf16CharacterStream(result, 0, result->length()); |
| 116 break; | 118 break; |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 timer->Start(); | 121 timer->Start(); |
| 120 scanner_->Initialize(stream_); | 122 scanner_->Initialize(stream_); |
| 121 } | 123 } |
| 122 | 124 |
| 123 ~BaselineScanner() { | 125 ~BaselineScanner() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 repeat); | 260 repeat); |
| 259 baseline_total += time.InMillisecondsF(); | 261 baseline_total += time.InMillisecondsF(); |
| 260 } | 262 } |
| 261 if (benchmark.empty()) benchmark = "Baseline"; | 263 if (benchmark.empty()) benchmark = "Baseline"; |
| 262 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), baseline_total); | 264 printf("%s(RunTime): %.f ms\n", benchmark.c_str(), baseline_total); |
| 263 } | 265 } |
| 264 } | 266 } |
| 265 v8::V8::Dispose(); | 267 v8::V8::Dispose(); |
| 266 return 0; | 268 return 0; |
| 267 } | 269 } |
| OLD | NEW |