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

Side by Side Diff: src/assembler.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 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/assembler.h ('k') | src/ia32/assembler-ia32.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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 double the_hole_nan; 99 double the_hole_nan;
100 }; 100 };
101 101
102 static DoubleConstant double_constants; 102 static DoubleConstant double_constants;
103 103
104 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; 104 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING";
105 105
106 // ----------------------------------------------------------------------------- 106 // -----------------------------------------------------------------------------
107 // Implementation of AssemblerBase 107 // Implementation of AssemblerBase
108 108
109 AssemblerBase::AssemblerBase(Isolate* isolate) 109 AssemblerBase::AssemblerBase(Isolate* isolate, void* buffer, int buffer_size)
110 : isolate_(isolate), 110 : isolate_(isolate),
111 jit_cookie_(0), 111 jit_cookie_(0),
112 emit_debug_code_(FLAG_debug_code), 112 emit_debug_code_(FLAG_debug_code),
113 predictable_code_size_(false) { 113 predictable_code_size_(false) {
114 if (FLAG_mask_constants_with_cookie && isolate != NULL) { 114 if (FLAG_mask_constants_with_cookie && isolate != NULL) {
115 jit_cookie_ = V8::RandomPrivate(isolate); 115 jit_cookie_ = V8::RandomPrivate(isolate);
116 } 116 }
117
118 if (buffer == NULL) {
119 // Do our own buffer management.
120 if (buffer_size <= kMinimalBufferSize) {
121 buffer_size = kMinimalBufferSize;
122 if (isolate->assembler_spare_buffer() != NULL) {
123 buffer = isolate->assembler_spare_buffer();
124 isolate->set_assembler_spare_buffer(NULL);
125 }
126 }
127 if (buffer == NULL) buffer = NewArray<byte>(buffer_size);
128 own_buffer_ = true;
129 } else {
130 // Use externally provided buffer instead.
131 ASSERT(buffer_size > 0);
132 own_buffer_ = false;
133 }
134 buffer_ = static_cast<byte*>(buffer);
135 buffer_size_ = buffer_size;
136
137 pc_ = buffer_;
138 }
139
140
141 AssemblerBase::~AssemblerBase() {
142 if (own_buffer_) {
143 if (isolate() != NULL &&
144 isolate()->assembler_spare_buffer() == NULL &&
145 buffer_size_ == kMinimalBufferSize) {
146 isolate()->set_assembler_spare_buffer(buffer_);
147 } else {
148 DeleteArray(buffer_);
149 }
150 }
117 } 151 }
118 152
119 153
120 // ----------------------------------------------------------------------------- 154 // -----------------------------------------------------------------------------
121 // Implementation of Label 155 // Implementation of Label
122 156
123 int Label::pos() const { 157 int Label::pos() const {
124 if (pos_ < 0) return -pos_ - 1; 158 if (pos_ < 0) return -pos_ - 1;
125 if (pos_ > 0) return pos_ - 1; 159 if (pos_ > 0) return pos_ - 1;
126 UNREACHABLE(); 160 UNREACHABLE();
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); 1431 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position);
1398 state_.written_position = state_.current_position; 1432 state_.written_position = state_.current_position;
1399 written = true; 1433 written = true;
1400 } 1434 }
1401 1435
1402 // Return whether something was written. 1436 // Return whether something was written.
1403 return written; 1437 return written;
1404 } 1438 }
1405 1439
1406 } } // namespace v8::internal 1440 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/ia32/assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698