Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: tools/parser-shell.cc

Issue 1110603005: Remove support for malloc'd typed arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/unittests/run-all-unittests.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 #include "src/compiler.h" 38 #include "src/compiler.h"
39 #include "src/scanner-character-streams.h" 39 #include "src/scanner-character-streams.h"
40 #include "tools/shell-utils.h" 40 #include "tools/shell-utils.h"
41 #include "src/parser.h" 41 #include "src/parser.h"
42 #include "src/preparse-data-format.h" 42 #include "src/preparse-data-format.h"
43 #include "src/preparse-data.h" 43 #include "src/preparse-data.h"
44 #include "src/preparser.h" 44 #include "src/preparser.h"
45 45
46 using namespace v8::internal; 46 using namespace v8::internal;
47 47
48 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
49 public:
50 virtual void* Allocate(size_t length) {
51 void* data = AllocateUninitialized(length);
52 return data == NULL ? data : memset(data, 0, length);
53 }
54 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
55 virtual void Free(void* data, size_t) { free(data); }
56 };
57
48 class StringResource8 : public v8::String::ExternalOneByteStringResource { 58 class StringResource8 : public v8::String::ExternalOneByteStringResource {
49 public: 59 public:
50 StringResource8(const char* data, int length) 60 StringResource8(const char* data, int length)
51 : data_(data), length_(length) { } 61 : data_(data), length_(length) { }
52 virtual size_t length() const { return length_; } 62 virtual size_t length() const { return length_; }
53 virtual const char* data() const { return data_; } 63 virtual const char* data() const { return data_; }
54 64
55 private: 65 private:
56 const char* data_; 66 const char* data_;
57 int length_; 67 int length_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 134 }
125 return std::make_pair(parse_time1, parse_time2); 135 return std::make_pair(parse_time1, parse_time2);
126 } 136 }
127 137
128 138
129 int main(int argc, char* argv[]) { 139 int main(int argc, char* argv[]) {
130 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 140 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
131 v8::V8::InitializeICU(); 141 v8::V8::InitializeICU();
132 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); 142 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
133 v8::V8::InitializePlatform(platform); 143 v8::V8::InitializePlatform(platform);
144 ArrayBufferAllocator array_buffer_allocator;
145 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
134 v8::V8::Initialize(); 146 v8::V8::Initialize();
135 Encoding encoding = LATIN1; 147 Encoding encoding = LATIN1;
136 std::vector<std::string> fnames; 148 std::vector<std::string> fnames;
137 std::string benchmark; 149 std::string benchmark;
138 int repeat = 1; 150 int repeat = 1;
139 for (int i = 0; i < argc; ++i) { 151 for (int i = 0; i < argc; ++i) {
140 if (strcmp(argv[i], "--latin1") == 0) { 152 if (strcmp(argv[i], "--latin1") == 0) {
141 encoding = LATIN1; 153 encoding = LATIN1;
142 } else if (strcmp(argv[i], "--utf8") == 0) { 154 } else if (strcmp(argv[i], "--utf8") == 0) {
143 encoding = UTF8; 155 encoding = UTF8;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 first_parse_total); 187 first_parse_total);
176 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(), 188 printf("%s(SecondParseRunTime): %.f ms\n", benchmark.c_str(),
177 second_parse_total); 189 second_parse_total);
178 } 190 }
179 } 191 }
180 v8::V8::Dispose(); 192 v8::V8::Dispose();
181 v8::V8::ShutdownPlatform(); 193 v8::V8::ShutdownPlatform();
182 delete platform; 194 delete platform;
183 return 0; 195 return 0;
184 } 196 }
OLDNEW
« no previous file with comments | « test/unittests/run-all-unittests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698