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

Side by Side Diff: src/compiler.cc

Issue 20018: Added check for logging enabled in two places where processing/allocation was... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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/mark-compact.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 // Compile the code. 115 // Compile the code.
116 Handle<Code> code = MakeCode(lit, script, is_eval); 116 Handle<Code> code = MakeCode(lit, script, is_eval);
117 117
118 // Check for stack-overflow exceptions. 118 // Check for stack-overflow exceptions.
119 if (code.is_null()) { 119 if (code.is_null()) {
120 Top::StackOverflow(); 120 Top::StackOverflow();
121 return Handle<JSFunction>::null(); 121 return Handle<JSFunction>::null();
122 } 122 }
123 123
124 if (script->name()->IsString()) { 124 #ifdef ENABLE_LOGGING_AND_PROFILING
125 SmartPointer<char> data = 125 // Log the code generation for the script. Check explicit whether logging is
126 String::cast(script->name())->ToCString(DISALLOW_NULLS); 126 // to avoid allocating when not required.
127 LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data)); 127 if (Logger::is_enabled()) {
128 } else { 128 if (script->name()->IsString()) {
129 LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, "")); 129 SmartPointer<char> data =
130 String::cast(script->name())->ToCString(DISALLOW_NULLS);
131 LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data));
132 } else {
133 LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, ""));
134 }
130 } 135 }
136 #endif
131 137
132 // Allocate function. 138 // Allocate function.
133 Handle<JSFunction> fun = 139 Handle<JSFunction> fun =
134 Factory::NewFunctionBoilerplate(lit->name(), 140 Factory::NewFunctionBoilerplate(lit->name(),
135 lit->materialized_literal_count(), 141 lit->materialized_literal_count(),
136 lit->contains_array_literal(), 142 lit->contains_array_literal(),
137 code); 143 code);
138 144
139 CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(), 145 CodeGenerator::SetFunctionInfo(fun, lit->scope()->num_parameters(),
140 RelocInfo::kNoPosition, 146 RelocInfo::kNoPosition,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 291
286 // Compile the code. 292 // Compile the code.
287 Handle<Code> code = MakeCode(lit, script, false); 293 Handle<Code> code = MakeCode(lit, script, false);
288 294
289 // Check for stack-overflow exception. 295 // Check for stack-overflow exception.
290 if (code.is_null()) { 296 if (code.is_null()) {
291 Top::StackOverflow(); 297 Top::StackOverflow();
292 return false; 298 return false;
293 } 299 }
294 300
295 // Generate the code, update the function info, and return the code.
296 #ifdef ENABLE_LOGGING_AND_PROFILING 301 #ifdef ENABLE_LOGGING_AND_PROFILING
297 if (script->name()->IsString()) { 302 // Log the code generation. If source information is available include script
298 int lineNum = script->GetLineNumber(start_position); 303 // name and line number. Check explicit whether logging is enabled as finding
299 if (lineNum > 0) { 304 // the line number is not for free.
300 lineNum += script->line_offset()->value() + 1; 305 if (Logger::is_enabled()) {
306 if (script->name()->IsString()) {
307 int lineNum = script->GetLineNumber(start_position);
308 if (lineNum > 0) {
309 lineNum += script->line_offset()->value() + 1;
310 }
311 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(),
312 String::cast(script->name()), lineNum));
313 } else {
314 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name()));
301 } 315 }
302 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(),
303 String::cast(script->name()), lineNum));
304 } else {
305 LOG(CodeCreateEvent("LazyCompile", *code, *lit->name()));
306 } 316 }
307 #endif 317 #endif
308 318
309 // Update the shared function info with the compiled code. 319 // Update the shared function info with the compiled code.
310 shared->set_code(*code); 320 shared->set_code(*code);
311 321
312 // Set the expected number of properties for instances. 322 // Set the expected number of properties for instances.
313 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 323 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
314 324
315 // Check the function has compiled code. 325 // Check the function has compiled code.
316 ASSERT(shared->is_compiled()); 326 ASSERT(shared->is_compiled());
317 return true; 327 return true;
318 } 328 }
319 329
320 330
321 } } // namespace v8::internal 331 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698