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

Side by Side Diff: test/cctest/interpreter/generate-bytecode-expectations.cc

Issue 2101413002: Provide a convenience array buffer allocator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 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 | « src/api.cc ('k') | test/fuzzer/fuzzer-support.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstring> 5 #include <cstring>
6 #include <fstream> 6 #include <fstream>
7 #include <vector> 7 #include <vector>
8 8
9 #include "test/cctest/interpreter/bytecode-expectations-printer.h" 9 #include "test/cctest/interpreter/bytecode-expectations-printer.h"
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool top_level_; 86 bool top_level_;
87 bool do_expressions_; 87 bool do_expressions_;
88 bool ignition_generators_; 88 bool ignition_generators_;
89 bool verbose_; 89 bool verbose_;
90 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_; 90 BytecodeExpectationsPrinter::ConstantPoolType const_pool_type_;
91 std::vector<std::string> input_filenames_; 91 std::vector<std::string> input_filenames_;
92 std::string output_filename_; 92 std::string output_filename_;
93 std::string test_function_name_; 93 std::string test_function_name_;
94 }; 94 };
95 95
96 class ArrayBufferAllocator final : public v8::ArrayBuffer::Allocator {
97 public:
98 void* Allocate(size_t length) override {
99 void* data = AllocateUninitialized(length);
100 if (data != nullptr) memset(data, 0, length);
101 return data;
102 }
103 void* AllocateUninitialized(size_t length) override { return malloc(length); }
104 void Free(void* data, size_t) override { free(data); }
105 };
106
107 class V8InitializationScope final { 96 class V8InitializationScope final {
108 public: 97 public:
109 explicit V8InitializationScope(const char* exec_path); 98 explicit V8InitializationScope(const char* exec_path);
110 ~V8InitializationScope(); 99 ~V8InitializationScope();
111 100
112 v8::Platform* platform() const { return platform_.get(); } 101 v8::Platform* platform() const { return platform_.get(); }
113 v8::Isolate* isolate() const { return isolate_; } 102 v8::Isolate* isolate() const { return isolate_; }
114 103
115 private: 104 private:
116 v8::base::SmartPointer<v8::Platform> platform_; 105 v8::base::SmartPointer<v8::Platform> platform_;
106 v8::base::SmartPointer<v8::ArrayBuffer::Allocator> allocator_;
117 v8::Isolate* isolate_; 107 v8::Isolate* isolate_;
118 108
119 DISALLOW_COPY_AND_ASSIGN(V8InitializationScope); 109 DISALLOW_COPY_AND_ASSIGN(V8InitializationScope);
120 }; 110 };
121 111
122 BytecodeExpectationsPrinter::ConstantPoolType ParseConstantPoolType( 112 BytecodeExpectationsPrinter::ConstantPoolType ParseConstantPoolType(
123 const char* type_string) { 113 const char* type_string) {
124 if (strcmp(type_string, "number") == 0) { 114 if (strcmp(type_string, "number") == 0) {
125 return BytecodeExpectationsPrinter::ConstantPoolType::kNumber; 115 return BytecodeExpectationsPrinter::ConstantPoolType::kNumber;
126 } else if (strcmp(type_string, "string") == 0) { 116 } else if (strcmp(type_string, "string") == 0) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 : platform_(v8::platform::CreateDefaultPlatform()) { 346 : platform_(v8::platform::CreateDefaultPlatform()) {
357 i::FLAG_ignition = true; 347 i::FLAG_ignition = true;
358 i::FLAG_always_opt = false; 348 i::FLAG_always_opt = false;
359 i::FLAG_allow_natives_syntax = true; 349 i::FLAG_allow_natives_syntax = true;
360 350
361 v8::V8::InitializeICUDefaultLocation(exec_path); 351 v8::V8::InitializeICUDefaultLocation(exec_path);
362 v8::V8::InitializeExternalStartupData(exec_path); 352 v8::V8::InitializeExternalStartupData(exec_path);
363 v8::V8::InitializePlatform(platform_.get()); 353 v8::V8::InitializePlatform(platform_.get());
364 v8::V8::Initialize(); 354 v8::V8::Initialize();
365 355
366 ArrayBufferAllocator allocator;
367 v8::Isolate::CreateParams create_params; 356 v8::Isolate::CreateParams create_params;
368 create_params.array_buffer_allocator = &allocator; 357 allocator_.Reset(v8::ArrayBuffer::Allocator::NewDefaultAllocator());
358 create_params.array_buffer_allocator = allocator_.get();
369 359
370 isolate_ = v8::Isolate::New(create_params); 360 isolate_ = v8::Isolate::New(create_params);
371 } 361 }
372 362
373 V8InitializationScope::~V8InitializationScope() { 363 V8InitializationScope::~V8InitializationScope() {
374 isolate_->Dispose(); 364 isolate_->Dispose();
375 v8::V8::Dispose(); 365 v8::V8::Dispose();
376 v8::V8::ShutdownPlatform(); 366 v8::V8::ShutdownPlatform();
377 } 367 }
378 368
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 } 565 }
576 } 566 }
577 567
578 if (!options.rebaseline()) { 568 if (!options.rebaseline()) {
579 if (!WriteExpectationsFile(snippet_list, platform, options, 569 if (!WriteExpectationsFile(snippet_list, platform, options,
580 options.output_filename())) { 570 options.output_filename())) {
581 return 3; 571 return 3;
582 } 572 }
583 } 573 }
584 } 574 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/fuzzer/fuzzer-support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698