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

Side by Side Diff: src/wasm/wasm-debug.cc

Issue 2344143003: Moved zones and zone related stuff in its own directory. (Closed)
Patch Set: Merge branch 'master' into zonefolder Created 4 years, 3 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/wasm/switch-logic.h ('k') | src/wasm/wasm-interpreter.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 "src/wasm/wasm-debug.h" 5 #include "src/wasm/wasm-debug.h"
6 6
7 #include "src/assert-scope.h" 7 #include "src/assert-scope.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 Handle<String> WasmDebugInfo::DisassembleFunction( 174 Handle<String> WasmDebugInfo::DisassembleFunction(
175 Handle<WasmDebugInfo> debug_info, int func_index) { 175 Handle<WasmDebugInfo> debug_info, int func_index) {
176 std::ostringstream disassembly_os; 176 std::ostringstream disassembly_os;
177 177
178 { 178 {
179 Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index); 179 Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index);
180 DisallowHeapAllocation no_gc; 180 DisallowHeapAllocation no_gc;
181 181
182 base::AccountingAllocator allocator; 182 AccountingAllocator allocator;
183 bool ok = PrintAst( 183 bool ok = PrintAst(
184 &allocator, FunctionBodyForTesting(bytes_vec.start(), bytes_vec.end()), 184 &allocator, FunctionBodyForTesting(bytes_vec.start(), bytes_vec.end()),
185 disassembly_os, nullptr); 185 disassembly_os, nullptr);
186 DCHECK(ok); 186 DCHECK(ok);
187 USE(ok); 187 USE(ok);
188 } 188 }
189 189
190 // Unfortunately, we have to copy the string here. 190 // Unfortunately, we have to copy the string here.
191 std::string code_str = disassembly_os.str(); 191 std::string code_str = disassembly_os.str();
192 CHECK_LE(code_str.length(), static_cast<size_t>(kMaxInt)); 192 CHECK_LE(code_str.length(), static_cast<size_t>(kMaxInt));
193 Factory *factory = debug_info->GetIsolate()->factory(); 193 Factory *factory = debug_info->GetIsolate()->factory();
194 Vector<const char> code_vec(code_str.data(), 194 Vector<const char> code_vec(code_str.data(),
195 static_cast<int>(code_str.length())); 195 static_cast<int>(code_str.length()));
196 return factory->NewStringFromAscii(code_vec).ToHandleChecked(); 196 return factory->NewStringFromAscii(code_vec).ToHandleChecked();
197 } 197 }
198 198
199 Handle<FixedArray> WasmDebugInfo::GetFunctionOffsetTable( 199 Handle<FixedArray> WasmDebugInfo::GetFunctionOffsetTable(
200 Handle<WasmDebugInfo> debug_info, int func_index) { 200 Handle<WasmDebugInfo> debug_info, int func_index) {
201 class NullBuf : public std::streambuf {}; 201 class NullBuf : public std::streambuf {};
202 NullBuf null_buf; 202 NullBuf null_buf;
203 std::ostream null_stream(&null_buf); 203 std::ostream null_stream(&null_buf);
204 204
205 std::vector<std::tuple<uint32_t, int, int>> offset_table_vec; 205 std::vector<std::tuple<uint32_t, int, int>> offset_table_vec;
206 206
207 { 207 {
208 Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index); 208 Vector<const uint8_t> bytes_vec = GetFunctionBytes(debug_info, func_index);
209 DisallowHeapAllocation no_gc; 209 DisallowHeapAllocation no_gc;
210 210
211 v8::base::AccountingAllocator allocator; 211 AccountingAllocator allocator;
212 bool ok = PrintAst( 212 bool ok = PrintAst(
213 &allocator, FunctionBodyForTesting(bytes_vec.start(), bytes_vec.end()), 213 &allocator, FunctionBodyForTesting(bytes_vec.start(), bytes_vec.end()),
214 null_stream, &offset_table_vec); 214 null_stream, &offset_table_vec);
215 DCHECK(ok); 215 DCHECK(ok);
216 USE(ok); 216 USE(ok);
217 } 217 }
218 218
219 size_t arr_size = 3 * offset_table_vec.size(); 219 size_t arr_size = 3 * offset_table_vec.size();
220 CHECK_LE(arr_size, static_cast<size_t>(kMaxInt)); 220 CHECK_LE(arr_size, static_cast<size_t>(kMaxInt));
221 Factory *factory = debug_info->GetIsolate()->factory(); 221 Factory *factory = debug_info->GetIsolate()->factory();
222 Handle<FixedArray> offset_table = 222 Handle<FixedArray> offset_table =
223 factory->NewFixedArray(static_cast<int>(arr_size), TENURED); 223 factory->NewFixedArray(static_cast<int>(arr_size), TENURED);
224 224
225 int idx = 0; 225 int idx = 0;
226 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) { 226 for (std::tuple<uint32_t, int, int> elem : offset_table_vec) {
227 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem))); 227 offset_table->set(idx++, Smi::FromInt(std::get<0>(elem)));
228 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem))); 228 offset_table->set(idx++, Smi::FromInt(std::get<1>(elem)));
229 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem))); 229 offset_table->set(idx++, Smi::FromInt(std::get<2>(elem)));
230 } 230 }
231 DCHECK_EQ(idx, offset_table->length()); 231 DCHECK_EQ(idx, offset_table->length());
232 232
233 return offset_table; 233 return offset_table;
234 } 234 }
OLDNEW
« no previous file with comments | « src/wasm/switch-logic.h ('k') | src/wasm/wasm-interpreter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698