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

Side by Side Diff: src/codegen.cc

Issue 165527: Refactor SetFunctionInfo to reduce long argument list (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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 | src/compiler.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 #endif 238 #endif
239 239
240 240
241 // Sets the function info on a function. 241 // Sets the function info on a function.
242 // The start_position points to the first '(' character after the function name 242 // The start_position points to the first '(' character after the function name
243 // in the full script source. When counting characters in the script source the 243 // in the full script source. When counting characters in the script source the
244 // the first character is number 0 (not 1). 244 // the first character is number 0 (not 1).
245 void CodeGenerator::SetFunctionInfo(Handle<JSFunction> fun, 245 void CodeGenerator::SetFunctionInfo(Handle<JSFunction> fun,
246 int length, 246 FunctionLiteral* lit,
247 int function_token_position,
248 int start_position,
249 int end_position,
250 bool is_expression,
251 bool is_toplevel, 247 bool is_toplevel,
252 Handle<Script> script, 248 Handle<Script> script) {
253 Handle<String> inferred_name) { 249 fun->shared()->set_length(lit->num_parameters());
254 fun->shared()->set_length(length); 250 fun->shared()->set_formal_parameter_count(lit->num_parameters());
255 fun->shared()->set_formal_parameter_count(length);
256 fun->shared()->set_script(*script); 251 fun->shared()->set_script(*script);
257 fun->shared()->set_function_token_position(function_token_position); 252 fun->shared()->set_function_token_position(lit->function_token_position());
258 fun->shared()->set_start_position(start_position); 253 fun->shared()->set_start_position(lit->start_position());
259 fun->shared()->set_end_position(end_position); 254 fun->shared()->set_end_position(lit->end_position());
260 fun->shared()->set_is_expression(is_expression); 255 fun->shared()->set_is_expression(lit->is_expression());
261 fun->shared()->set_is_toplevel(is_toplevel); 256 fun->shared()->set_is_toplevel(is_toplevel);
262 fun->shared()->set_inferred_name(*inferred_name); 257 fun->shared()->set_inferred_name(*lit->inferred_name());
263 } 258 }
264 259
265 260
266 static Handle<Code> ComputeLazyCompile(int argc) { 261 static Handle<Code> ComputeLazyCompile(int argc) {
267 CALL_HEAP_FUNCTION(StubCache::ComputeLazyCompile(argc), Code); 262 CALL_HEAP_FUNCTION(StubCache::ComputeLazyCompile(argc), Code);
268 } 263 }
269 264
270 265
271 Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) { 266 Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) {
272 #ifdef DEBUG 267 #ifdef DEBUG
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 code->instruction_size()); 305 code->instruction_size());
311 #endif 306 #endif
312 } 307 }
313 308
314 // Create a boilerplate function. 309 // Create a boilerplate function.
315 Handle<JSFunction> function = 310 Handle<JSFunction> function =
316 Factory::NewFunctionBoilerplate(node->name(), 311 Factory::NewFunctionBoilerplate(node->name(),
317 node->materialized_literal_count(), 312 node->materialized_literal_count(),
318 node->contains_array_literal(), 313 node->contains_array_literal(),
319 code); 314 code);
320 CodeGenerator::SetFunctionInfo(function, node->num_parameters(), 315 CodeGenerator::SetFunctionInfo(function, node, false, script_);
321 node->function_token_position(),
322 node->start_position(), node->end_position(),
323 node->is_expression(), false, script_,
324 node->inferred_name());
325 316
326 #ifdef ENABLE_DEBUGGER_SUPPORT 317 #ifdef ENABLE_DEBUGGER_SUPPORT
327 // Notify debugger that a new function has been added. 318 // Notify debugger that a new function has been added.
328 Debugger::OnNewFunction(function); 319 Debugger::OnNewFunction(function);
329 #endif 320 #endif
330 321
331 // Set the expected number of properties for instances and return 322 // Set the expected number of properties for instances and return
332 // the resulting function. 323 // the resulting function.
333 SetExpectedNofPropertiesFromEstimate(function, 324 SetExpectedNofPropertiesFromEstimate(function,
334 node->expected_property_count()); 325 node->expected_property_count());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { 520 void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
530 switch (type_) { 521 switch (type_) {
531 case READ_LENGTH: GenerateReadLength(masm); break; 522 case READ_LENGTH: GenerateReadLength(masm); break;
532 case READ_ELEMENT: GenerateReadElement(masm); break; 523 case READ_ELEMENT: GenerateReadElement(masm); break;
533 case NEW_OBJECT: GenerateNewObject(masm); break; 524 case NEW_OBJECT: GenerateNewObject(masm); break;
534 } 525 }
535 } 526 }
536 527
537 528
538 } } // namespace v8::internal 529 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698