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

Side by Side Diff: src/compiler.cc

Issue 2908009: Create a separate class to encapsulate ScopeInfo serialization.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 5 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 | « src/accessors.cc ('k') | src/contexts.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return CodeGenerator::MakeCode(info); 153 return CodeGenerator::MakeCode(info);
154 } 154 }
155 155
156 156
157 #ifdef ENABLE_DEBUGGER_SUPPORT 157 #ifdef ENABLE_DEBUGGER_SUPPORT
158 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { 158 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) {
159 Handle<Context> context = Handle<Context>::null(); 159 Handle<Context> context = Handle<Context>::null();
160 Handle<Code> code = MakeCode(context, info); 160 Handle<Code> code = MakeCode(context, info);
161 if (!info->shared_info().is_null()) { 161 if (!info->shared_info().is_null()) {
162 info->shared_info()->set_scope_info( 162 info->shared_info()->set_scope_info(
163 *ScopeInfo<>::CreateHeapObject(info->scope())); 163 *SerializedScopeInfo::Create(info->scope()));
164 } 164 }
165 return code; 165 return code;
166 } 166 }
167 #endif 167 #endif
168 168
169 169
170 static Handle<SharedFunctionInfo> MakeFunctionInfo(bool is_global, 170 static Handle<SharedFunctionInfo> MakeFunctionInfo(bool is_global,
171 bool is_eval, 171 bool is_eval,
172 Compiler::ValidationState validate, 172 Compiler::ValidationState validate,
173 Handle<Script> script, 173 Handle<Script> script,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 code->instruction_start(), 255 code->instruction_start(),
256 code->instruction_size())); 256 code->instruction_size()));
257 } 257 }
258 258
259 // Allocate function. 259 // Allocate function.
260 Handle<SharedFunctionInfo> result = 260 Handle<SharedFunctionInfo> result =
261 Factory::NewSharedFunctionInfo( 261 Factory::NewSharedFunctionInfo(
262 lit->name(), 262 lit->name(),
263 lit->materialized_literal_count(), 263 lit->materialized_literal_count(),
264 code, 264 code,
265 ScopeInfo<>::CreateHeapObject(info.scope())); 265 SerializedScopeInfo::Create(info.scope()));
266 266
267 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 267 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
268 Compiler::SetFunctionInfo(result, lit, true, script); 268 Compiler::SetFunctionInfo(result, lit, true, script);
269 269
270 // Hint to the runtime system used when allocating space for initial 270 // Hint to the runtime system used when allocating space for initial
271 // property space by setting the expected number of properties for 271 // property space by setting the expected number of properties for
272 // the instances of the function. 272 // the instances of the function.
273 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); 273 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count());
274 274
275 #ifdef ENABLE_DEBUGGER_SUPPORT 275 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, 444 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG,
445 name, 445 name,
446 Handle<String>(shared->inferred_name()), 446 Handle<String>(shared->inferred_name()),
447 start_position, 447 start_position,
448 info->script(), 448 info->script(),
449 code); 449 code);
450 450
451 // Update the shared function info with the compiled code and the scope info. 451 // Update the shared function info with the compiled code and the scope info.
452 shared->set_code(*code); 452 shared->set_code(*code);
453 shared->set_scope_info(*ScopeInfo<>::CreateHeapObject(info->scope())); 453 shared->set_scope_info(*SerializedScopeInfo::Create(info->scope()));
454 454
455 // Set the expected number of properties for instances. 455 // Set the expected number of properties for instances.
456 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 456 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
457 457
458 // Set the optimication hints after performing lazy compilation, as these are 458 // Set the optimication hints after performing lazy compilation, as these are
459 // not set when the function is set up as a lazily compiled function. 459 // not set when the function is set up as a lazily compiled function.
460 shared->SetThisPropertyAssignmentsInfo( 460 shared->SetThisPropertyAssignmentsInfo(
461 lit->has_only_simple_this_property_assignments(), 461 lit->has_only_simple_this_property_assignments(),
462 *lit->this_property_assignments()); 462 *lit->this_property_assignments());
463 463
(...skipping 14 matching lines...) Expand all
478 #endif 478 #endif
479 479
480 // Determine if the function can be lazily compiled. This is 480 // Determine if the function can be lazily compiled. This is
481 // necessary to allow some of our builtin JS files to be lazily 481 // necessary to allow some of our builtin JS files to be lazily
482 // compiled. These builtins cannot be handled lazily by the parser, 482 // compiled. These builtins cannot be handled lazily by the parser,
483 // since we have to know if a function uses the special natives 483 // since we have to know if a function uses the special natives
484 // syntax, which is something the parser records. 484 // syntax, which is something the parser records.
485 bool allow_lazy = literal->AllowsLazyCompilation() && 485 bool allow_lazy = literal->AllowsLazyCompilation() &&
486 !LiveEditFunctionTracker::IsActive(); 486 !LiveEditFunctionTracker::IsActive();
487 487
488 Handle<Object> scope_info(ScopeInfo<>::EmptyHeapObject()); 488 Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty());
489 489
490 // Generate code 490 // Generate code
491 Handle<Code> code; 491 Handle<Code> code;
492 if (FLAG_lazy && allow_lazy) { 492 if (FLAG_lazy && allow_lazy) {
493 code = ComputeLazyCompile(literal->num_parameters()); 493 code = ComputeLazyCompile(literal->num_parameters());
494 } else { 494 } else {
495 // The bodies of function literals have not yet been visited by 495 // The bodies of function literals have not yet been visited by
496 // the AST optimizer/analyzer. 496 // the AST optimizer/analyzer.
497 if (!Rewriter::Optimize(literal)) { 497 if (!Rewriter::Optimize(literal)) {
498 return Handle<SharedFunctionInfo>::null(); 498 return Handle<SharedFunctionInfo>::null();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return Handle<SharedFunctionInfo>::null(); 561 return Handle<SharedFunctionInfo>::null();
562 } 562 }
563 563
564 // Function compilation complete. 564 // Function compilation complete.
565 RecordFunctionCompilation(Logger::FUNCTION_TAG, 565 RecordFunctionCompilation(Logger::FUNCTION_TAG,
566 literal->name(), 566 literal->name(),
567 literal->inferred_name(), 567 literal->inferred_name(),
568 literal->start_position(), 568 literal->start_position(),
569 script, 569 script,
570 code); 570 code);
571 scope_info = ScopeInfo<>::CreateHeapObject(info.scope()); 571 scope_info = SerializedScopeInfo::Create(info.scope());
572 } 572 }
573 573
574 // Create a shared function info object. 574 // Create a shared function info object.
575 Handle<SharedFunctionInfo> result = 575 Handle<SharedFunctionInfo> result =
576 Factory::NewSharedFunctionInfo(literal->name(), 576 Factory::NewSharedFunctionInfo(literal->name(),
577 literal->materialized_literal_count(), 577 literal->materialized_literal_count(),
578 code, 578 code,
579 scope_info); 579 scope_info);
580 SetFunctionInfo(result, literal, false, script); 580 SetFunctionInfo(result, literal, false, script);
581 581
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 641 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
642 *code, *func_name)); 642 *code, *func_name));
643 OPROFILE(CreateNativeCodeRegion(*func_name, 643 OPROFILE(CreateNativeCodeRegion(*func_name,
644 code->instruction_start(), 644 code->instruction_start(),
645 code->instruction_size())); 645 code->instruction_size()));
646 } 646 }
647 } 647 }
648 } 648 }
649 649
650 } } // namespace v8::internal 650 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698