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

Side by Side Diff: src/compiler.cc

Issue 2918001: Move serialized scope info from Code object to SharedFunctionInfo. (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/codegen.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 22 matching lines...) Expand all
33 #include "compiler.h" 33 #include "compiler.h"
34 #include "data-flow.h" 34 #include "data-flow.h"
35 #include "debug.h" 35 #include "debug.h"
36 #include "fast-codegen.h" 36 #include "fast-codegen.h"
37 #include "flow-graph.h" 37 #include "flow-graph.h"
38 #include "full-codegen.h" 38 #include "full-codegen.h"
39 #include "liveedit.h" 39 #include "liveedit.h"
40 #include "oprofile-agent.h" 40 #include "oprofile-agent.h"
41 #include "rewriter.h" 41 #include "rewriter.h"
42 #include "scopes.h" 42 #include "scopes.h"
43 #include "scopeinfo.h"
43 44
44 namespace v8 { 45 namespace v8 {
45 namespace internal { 46 namespace internal {
46 47
47 // For normal operation the syntax checker is used to determine whether to 48 // For normal operation the syntax checker is used to determine whether to
48 // use the full compiler for top level code or not. However if the flag 49 // use the full compiler for top level code or not. However if the flag
49 // --always-full-compiler is specified or debugging is active the full 50 // --always-full-compiler is specified or debugging is active the full
50 // compiler will be used for all code. 51 // compiler will be used for all code.
51 static bool AlwaysFullCompiler() { 52 static bool AlwaysFullCompiler() {
52 #ifdef ENABLE_DEBUGGER_SUPPORT 53 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 150 }
150 } 151 }
151 152
152 return CodeGenerator::MakeCode(info); 153 return CodeGenerator::MakeCode(info);
153 } 154 }
154 155
155 156
156 #ifdef ENABLE_DEBUGGER_SUPPORT 157 #ifdef ENABLE_DEBUGGER_SUPPORT
157 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) { 158 Handle<Code> MakeCodeForLiveEdit(CompilationInfo* info) {
158 Handle<Context> context = Handle<Context>::null(); 159 Handle<Context> context = Handle<Context>::null();
159 return MakeCode(context, info); 160 Handle<Code> code = MakeCode(context, info);
161 if (!info->shared_info().is_null()) {
162 info->shared_info()->set_scope_info(
163 *ScopeInfo<>::CreateHeapObject(info->scope()));
164 }
165 return code;
160 } 166 }
161 #endif 167 #endif
162 168
163 169
164 static Handle<SharedFunctionInfo> MakeFunctionInfo(bool is_global, 170 static Handle<SharedFunctionInfo> MakeFunctionInfo(bool is_global,
165 bool is_eval, 171 bool is_eval,
166 Compiler::ValidationState validate, 172 Compiler::ValidationState validate,
167 Handle<Script> script, 173 Handle<Script> script,
168 Handle<Context> context, 174 Handle<Context> context,
169 v8::Extension* extension, 175 v8::Extension* extension,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 is_eval ? Logger::EVAL_TAG : 251 is_eval ? Logger::EVAL_TAG :
246 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 252 Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
247 *code, "")); 253 *code, ""));
248 OPROFILE(CreateNativeCodeRegion(is_eval ? "Eval" : "Script", 254 OPROFILE(CreateNativeCodeRegion(is_eval ? "Eval" : "Script",
249 code->instruction_start(), 255 code->instruction_start(),
250 code->instruction_size())); 256 code->instruction_size()));
251 } 257 }
252 258
253 // Allocate function. 259 // Allocate function.
254 Handle<SharedFunctionInfo> result = 260 Handle<SharedFunctionInfo> result =
255 Factory::NewSharedFunctionInfo(lit->name(), 261 Factory::NewSharedFunctionInfo(
256 lit->materialized_literal_count(), 262 lit->name(),
257 code); 263 lit->materialized_literal_count(),
264 code,
265 ScopeInfo<>::CreateHeapObject(info.scope()));
258 266
259 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 267 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
260 Compiler::SetFunctionInfo(result, lit, true, script); 268 Compiler::SetFunctionInfo(result, lit, true, script);
261 269
262 // Hint to the runtime system used when allocating space for initial 270 // Hint to the runtime system used when allocating space for initial
263 // property space by setting the expected number of properties for 271 // property space by setting the expected number of properties for
264 // the instances of the function. 272 // the instances of the function.
265 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); 273 SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count());
266 274
267 #ifdef ENABLE_DEBUGGER_SUPPORT 275 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return false; 446 return false;
439 } 447 }
440 448
441 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, 449 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG,
442 name, 450 name,
443 Handle<String>(shared->inferred_name()), 451 Handle<String>(shared->inferred_name()),
444 start_position, 452 start_position,
445 info->script(), 453 info->script(),
446 code); 454 code);
447 455
448 // Update the shared function info with the compiled code. 456 // Update the shared function info with the compiled code and the scope info.
449 shared->set_code(*code); 457 shared->set_code(*code);
458 shared->set_scope_info(*ScopeInfo<>::CreateHeapObject(info->scope()));
450 459
451 // Set the expected number of properties for instances. 460 // Set the expected number of properties for instances.
452 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count()); 461 SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
453 462
454 // Set the optimication hints after performing lazy compilation, as these are 463 // Set the optimication hints after performing lazy compilation, as these are
455 // not set when the function is set up as a lazily compiled function. 464 // not set when the function is set up as a lazily compiled function.
456 shared->SetThisPropertyAssignmentsInfo( 465 shared->SetThisPropertyAssignmentsInfo(
457 lit->has_only_simple_this_property_assignments(), 466 lit->has_only_simple_this_property_assignments(),
458 *lit->this_property_assignments()); 467 *lit->this_property_assignments());
459 468
(...skipping 14 matching lines...) Expand all
474 #endif 483 #endif
475 484
476 // Determine if the function can be lazily compiled. This is 485 // Determine if the function can be lazily compiled. This is
477 // necessary to allow some of our builtin JS files to be lazily 486 // necessary to allow some of our builtin JS files to be lazily
478 // compiled. These builtins cannot be handled lazily by the parser, 487 // compiled. These builtins cannot be handled lazily by the parser,
479 // since we have to know if a function uses the special natives 488 // since we have to know if a function uses the special natives
480 // syntax, which is something the parser records. 489 // syntax, which is something the parser records.
481 bool allow_lazy = literal->AllowsLazyCompilation() && 490 bool allow_lazy = literal->AllowsLazyCompilation() &&
482 !LiveEditFunctionTracker::IsActive(); 491 !LiveEditFunctionTracker::IsActive();
483 492
493 Handle<Object> scope_info(ScopeInfo<>::EmptyHeapObject());
494
484 // Generate code 495 // Generate code
485 Handle<Code> code; 496 Handle<Code> code;
486 if (FLAG_lazy && allow_lazy) { 497 if (FLAG_lazy && allow_lazy) {
487 code = ComputeLazyCompile(literal->num_parameters()); 498 code = ComputeLazyCompile(literal->num_parameters());
488 } else { 499 } else {
489 // The bodies of function literals have not yet been visited by 500 // The bodies of function literals have not yet been visited by
490 // the AST optimizer/analyzer. 501 // the AST optimizer/analyzer.
491 if (!Rewriter::Optimize(literal)) { 502 if (!Rewriter::Optimize(literal)) {
492 return Handle<SharedFunctionInfo>::null(); 503 return Handle<SharedFunctionInfo>::null();
493 } 504 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 return Handle<SharedFunctionInfo>::null(); 566 return Handle<SharedFunctionInfo>::null();
556 } 567 }
557 568
558 // Function compilation complete. 569 // Function compilation complete.
559 RecordFunctionCompilation(Logger::FUNCTION_TAG, 570 RecordFunctionCompilation(Logger::FUNCTION_TAG,
560 literal->name(), 571 literal->name(),
561 literal->inferred_name(), 572 literal->inferred_name(),
562 literal->start_position(), 573 literal->start_position(),
563 script, 574 script,
564 code); 575 code);
576 scope_info = ScopeInfo<>::CreateHeapObject(info.scope());
565 } 577 }
566 578
567 // Create a shared function info object. 579 // Create a shared function info object.
568 Handle<SharedFunctionInfo> result = 580 Handle<SharedFunctionInfo> result =
569 Factory::NewSharedFunctionInfo(literal->name(), 581 Factory::NewSharedFunctionInfo(literal->name(),
570 literal->materialized_literal_count(), 582 literal->materialized_literal_count(),
571 code); 583 code,
584 scope_info);
572 SetFunctionInfo(result, literal, false, script); 585 SetFunctionInfo(result, literal, false, script);
573 586
574 // Set the expected number of properties for instances and return 587 // Set the expected number of properties for instances and return
575 // the resulting function. 588 // the resulting function.
576 SetExpectedNofPropertiesFromEstimate(result, 589 SetExpectedNofPropertiesFromEstimate(result,
577 literal->expected_property_count()); 590 literal->expected_property_count());
578 live_edit_tracker.RecordFunctionInfo(result, literal); 591 live_edit_tracker.RecordFunctionInfo(result, literal);
579 return result; 592 return result;
580 } 593 }
581 594
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), 646 PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
634 *code, *func_name)); 647 *code, *func_name));
635 OPROFILE(CreateNativeCodeRegion(*func_name, 648 OPROFILE(CreateNativeCodeRegion(*func_name,
636 code->instruction_start(), 649 code->instruction_start(),
637 code->instruction_size())); 650 code->instruction_size()));
638 } 651 }
639 } 652 }
640 } 653 }
641 654
642 } } // namespace v8::internal 655 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698