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

Side by Side Diff: src/mips/assembler-mips.cc

Issue 11416133: Moved buffer handling to AssemblerBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/mips/assembler-mips.h ('k') | src/x64/assembler-x64.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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 const Instr kSwRegFpNegOffsetPattern = SW | (kRegister_fp_Code << kRsShift) 261 const Instr kSwRegFpNegOffsetPattern = SW | (kRegister_fp_Code << kRsShift)
262 | (kNegOffset & kImm16Mask); 262 | (kNegOffset & kImm16Mask);
263 // A mask for the Rt register for push, pop, lw, sw instructions. 263 // A mask for the Rt register for push, pop, lw, sw instructions.
264 const Instr kRtMask = kRtFieldMask; 264 const Instr kRtMask = kRtFieldMask;
265 const Instr kLwSwInstrTypeMask = 0xffe00000; 265 const Instr kLwSwInstrTypeMask = 0xffe00000;
266 const Instr kLwSwInstrArgumentMask = ~kLwSwInstrTypeMask; 266 const Instr kLwSwInstrArgumentMask = ~kLwSwInstrTypeMask;
267 const Instr kLwSwOffsetMask = kImm16Mask; 267 const Instr kLwSwOffsetMask = kImm16Mask;
268 268
269 269
270 // Spare buffer. 270 Assembler::Assembler(Isolate* isolate, void* buffer, int buffer_size)
271 static const int kMinimalBufferSize = 4 * KB; 271 : AssemblerBase(isolate, buffer, buffer_size),
272
273
274 Assembler::Assembler(Isolate* arg_isolate, void* buffer, int buffer_size)
275 : AssemblerBase(arg_isolate),
276 recorded_ast_id_(TypeFeedbackId::None()), 272 recorded_ast_id_(TypeFeedbackId::None()),
277 positions_recorder_(this) { 273 positions_recorder_(this) {
278 if (buffer == NULL) { 274 reloc_info_writer.Reposition(buffer_ + buffer_size_, pc_);
279 // Do our own buffer management.
280 if (buffer_size <= kMinimalBufferSize) {
281 buffer_size = kMinimalBufferSize;
282
283 if (isolate()->assembler_spare_buffer() != NULL) {
284 buffer = isolate()->assembler_spare_buffer();
285 isolate()->set_assembler_spare_buffer(NULL);
286 }
287 }
288 if (buffer == NULL) {
289 buffer_ = NewArray<byte>(buffer_size);
290 } else {
291 buffer_ = static_cast<byte*>(buffer);
292 }
293 buffer_size_ = buffer_size;
294 own_buffer_ = true;
295
296 } else {
297 // Use externally provided buffer instead.
298 ASSERT(buffer_size > 0);
299 buffer_ = static_cast<byte*>(buffer);
300 buffer_size_ = buffer_size;
301 own_buffer_ = false;
302 }
303
304 // Set up buffer pointers.
305 ASSERT(buffer_ != NULL);
306 pc_ = buffer_;
307 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
308 275
309 last_trampoline_pool_end_ = 0; 276 last_trampoline_pool_end_ = 0;
310 no_trampoline_pool_before_ = 0; 277 no_trampoline_pool_before_ = 0;
311 trampoline_pool_blocked_nesting_ = 0; 278 trampoline_pool_blocked_nesting_ = 0;
312 // We leave space (16 * kTrampolineSlotsSize) 279 // We leave space (16 * kTrampolineSlotsSize)
313 // for BlockTrampolinePoolScope buffer. 280 // for BlockTrampolinePoolScope buffer.
314 next_buffer_check_ = kMaxBranchOffset - kTrampolineSlotsSize * 16; 281 next_buffer_check_ = kMaxBranchOffset - kTrampolineSlotsSize * 16;
315 internal_trampoline_exception_ = false; 282 internal_trampoline_exception_ = false;
316 last_bound_pos_ = 0; 283 last_bound_pos_ = 0;
317 284
318 trampoline_emitted_ = false; 285 trampoline_emitted_ = false;
319 unbound_labels_count_ = 0; 286 unbound_labels_count_ = 0;
320 block_buffer_growth_ = false; 287 block_buffer_growth_ = false;
321 288
322 ClearRecordedAstId(); 289 ClearRecordedAstId();
323 } 290 }
324 291
325 292
326 Assembler::~Assembler() {
327 if (own_buffer_) {
328 if (isolate()->assembler_spare_buffer() == NULL &&
329 buffer_size_ == kMinimalBufferSize) {
330 isolate()->set_assembler_spare_buffer(buffer_);
331 } else {
332 DeleteArray(buffer_);
333 }
334 }
335 }
336
337
338 void Assembler::GetCode(CodeDesc* desc) { 293 void Assembler::GetCode(CodeDesc* desc) {
339 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap. 294 ASSERT(pc_ <= reloc_info_writer.pos()); // No overlap.
340 // Set up code descriptor. 295 // Set up code descriptor.
341 desc->buffer = buffer_; 296 desc->buffer = buffer_;
342 desc->buffer_size = buffer_size_; 297 desc->buffer_size = buffer_size_;
343 desc->instr_size = pc_offset(); 298 desc->instr_size = pc_offset();
344 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos(); 299 desc->reloc_size = (buffer_ + buffer_size_) - reloc_info_writer.pos();
345 } 300 }
346 301
347 302
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 } 2240 }
2286 2241
2287 if (patched) { 2242 if (patched) {
2288 CPU::FlushICache(pc+2, sizeof(Address)); 2243 CPU::FlushICache(pc+2, sizeof(Address));
2289 } 2244 }
2290 } 2245 }
2291 2246
2292 } } // namespace v8::internal 2247 } } // namespace v8::internal
2293 2248
2294 #endif // V8_TARGET_ARCH_MIPS 2249 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/assembler-mips.h ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698