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

Side by Side Diff: runtime/bin/filter.cc

Issue 12812006: Avoid massive stack frames by allocating 64k buffers in the heap. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/filter.h" 6 #include "bin/filter.h"
7 #include "bin/io_buffer.h" 7 #include "bin/io_buffer.h"
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 void FUNCTION_NAME(Filter_Processed)(Dart_NativeArguments args) { 126 void FUNCTION_NAME(Filter_Processed)(Dart_NativeArguments args) {
127 Dart_EnterScope(); 127 Dart_EnterScope();
128 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0); 128 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
129 Filter* filter = GetFilter(filter_obj); 129 Filter* filter = GetFilter(filter_obj);
130 Dart_Handle flush_obj = Dart_GetNativeArgument(args, 1); 130 Dart_Handle flush_obj = Dart_GetNativeArgument(args, 1);
131 bool flush; 131 bool flush;
132 if (Dart_IsError(Dart_BooleanValue(flush_obj, &flush))) { 132 if (Dart_IsError(Dart_BooleanValue(flush_obj, &flush))) {
133 Dart_ThrowException(DartUtils::NewInternalError( 133 Dart_ThrowException(DartUtils::NewInternalError(
134 "Failed to get 'flush' parameter")); 134 "Failed to get 'flush' parameter"));
135 } 135 }
136 uint8_t buffer[kFilterBufferLength]; 136 uint8_t* buffer = new uint8_t[kFilterBufferLength];
siva 2013/03/15 07:47:00 Not sure how frequently this function is called bu
Mads Ager (google) 2013/03/15 09:24:56 I don't have any data on how often this is called
137 intptr_t read = filter->Processed(buffer, kFilterBufferLength, flush); 137 intptr_t read = filter->Processed(buffer, kFilterBufferLength, flush);
138 if (read < 0) { 138 if (read < 0) {
139 // Error, end filter. 139 // Error, end filter.
140 EndFilter(filter_obj, filter); 140 EndFilter(filter_obj, filter);
141 delete[] buffer;
141 Dart_ThrowException(DartUtils::NewInternalError( 142 Dart_ThrowException(DartUtils::NewInternalError(
142 "Filter error, bad data")); 143 "Filter error, bad data"));
143 } else if (read == 0) { 144 } else if (read == 0) {
144 Dart_SetReturnValue(args, Dart_Null()); 145 Dart_SetReturnValue(args, Dart_Null());
145 } else { 146 } else {
146 uint8_t* io_buffer; 147 uint8_t* io_buffer;
147 Dart_Handle result = IOBuffer::Allocate(read, &io_buffer); 148 Dart_Handle result = IOBuffer::Allocate(read, &io_buffer);
148 memmove(io_buffer, buffer, read); 149 memmove(io_buffer, buffer, read);
149 Dart_SetReturnValue(args, result); 150 Dart_SetReturnValue(args, result);
150 } 151 }
152 delete[] buffer;
151 Dart_ExitScope(); 153 Dart_ExitScope();
152 } 154 }
153 155
154 156
155 void FUNCTION_NAME(Filter_End)(Dart_NativeArguments args) { 157 void FUNCTION_NAME(Filter_End)(Dart_NativeArguments args) {
156 Dart_EnterScope(); 158 Dart_EnterScope();
157 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0); 159 Dart_Handle filter_obj = Dart_GetNativeArgument(args, 0);
158 Filter* filter = GetFilter(filter_obj); 160 Filter* filter = GetFilter(filter_obj);
159 EndFilter(filter_obj, filter); 161 EndFilter(filter_obj, filter);
160 Dart_ExitScope(); 162 Dart_ExitScope();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 case Z_NEED_DICT: 305 case Z_NEED_DICT:
304 case Z_DATA_ERROR: 306 case Z_DATA_ERROR:
305 case Z_STREAM_ERROR: 307 case Z_STREAM_ERROR:
306 // An error occoured. 308 // An error occoured.
307 delete[] current_buffer; 309 delete[] current_buffer;
308 current_buffer = NULL; 310 current_buffer = NULL;
309 return -1; 311 return -1;
310 } 312 }
311 } 313 }
312 314
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698