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

Side by Side Diff: src/compiler.cc

Issue 16337005: Deprecate FACTORY helper macro. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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/bootstrapper.cc ('k') | src/d8.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 // No cache entry found. Do pre-parsing, if it makes sense, and compile 643 // No cache entry found. Do pre-parsing, if it makes sense, and compile
644 // the script. 644 // the script.
645 // Building preparse data that is only used immediately after is only a 645 // Building preparse data that is only used immediately after is only a
646 // saving if we might skip building the AST for lazily compiled functions. 646 // saving if we might skip building the AST for lazily compiled functions.
647 // I.e., preparse data isn't relevant when the lazy flag is off, and 647 // I.e., preparse data isn't relevant when the lazy flag is off, and
648 // for small sources, odds are that there aren't many functions 648 // for small sources, odds are that there aren't many functions
649 // that would be compiled lazily anyway, so we skip the preparse step 649 // that would be compiled lazily anyway, so we skip the preparse step
650 // in that case too. 650 // in that case too.
651 651
652 // Create a script object describing the script to be compiled. 652 // Create a script object describing the script to be compiled.
653 Handle<Script> script = FACTORY->NewScript(source); 653 Handle<Script> script = isolate->factory()->NewScript(source);
654 if (natives == NATIVES_CODE) { 654 if (natives == NATIVES_CODE) {
655 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); 655 script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
656 } 656 }
657 if (!script_name.is_null()) { 657 if (!script_name.is_null()) {
658 script->set_name(*script_name); 658 script->set_name(*script_name);
659 script->set_line_offset(Smi::FromInt(line_offset)); 659 script->set_line_offset(Smi::FromInt(line_offset));
660 script->set_column_offset(Smi::FromInt(column_offset)); 660 script->set_column_offset(Smi::FromInt(column_offset));
661 } 661 }
662 662
663 script->set_data(script_data.is_null() ? HEAP->undefined_value() 663 script->set_data(script_data.is_null() ? HEAP->undefined_value()
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 1048
1049 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, 1049 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
1050 Handle<Script> script) { 1050 Handle<Script> script) {
1051 // Precondition: code has been parsed and scopes have been analyzed. 1051 // Precondition: code has been parsed and scopes have been analyzed.
1052 CompilationInfoWithZone info(script); 1052 CompilationInfoWithZone info(script);
1053 info.SetFunction(literal); 1053 info.SetFunction(literal);
1054 info.SetScope(literal->scope()); 1054 info.SetScope(literal->scope());
1055 info.SetLanguageMode(literal->scope()->language_mode()); 1055 info.SetLanguageMode(literal->scope()->language_mode());
1056 1056
1057 Isolate* isolate = info.isolate(); 1057 Isolate* isolate = info.isolate();
1058 Factory* factory = isolate->factory();
1058 LiveEditFunctionTracker live_edit_tracker(isolate, literal); 1059 LiveEditFunctionTracker live_edit_tracker(isolate, literal);
1059 // Determine if the function can be lazily compiled. This is necessary to 1060 // Determine if the function can be lazily compiled. This is necessary to
1060 // allow some of our builtin JS files to be lazily compiled. These 1061 // allow some of our builtin JS files to be lazily compiled. These
1061 // builtins cannot be handled lazily by the parser, since we have to know 1062 // builtins cannot be handled lazily by the parser, since we have to know
1062 // if a function uses the special natives syntax, which is something the 1063 // if a function uses the special natives syntax, which is something the
1063 // parser records. 1064 // parser records.
1064 // If the debugger requests compilation for break points, we cannot be 1065 // If the debugger requests compilation for break points, we cannot be
1065 // aggressive about lazy compilation, because it might trigger compilation 1066 // aggressive about lazy compilation, because it might trigger compilation
1066 // of functions without an outer context when setting a breakpoint through 1067 // of functions without an outer context when setting a breakpoint through
1067 // Debug::FindSharedFunctionInfoInScript. 1068 // Debug::FindSharedFunctionInfoInScript.
1068 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); 1069 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext();
1069 bool allow_lazy = literal->AllowsLazyCompilation() && 1070 bool allow_lazy = literal->AllowsLazyCompilation() &&
1070 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx); 1071 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx);
1071 1072
1072 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate)); 1073 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate));
1073 1074
1074 // Generate code 1075 // Generate code
1075 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { 1076 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) {
1076 Handle<Code> code = isolate->builtins()->LazyCompile(); 1077 Handle<Code> code = isolate->builtins()->LazyCompile();
1077 info.SetCode(code); 1078 info.SetCode(code);
1078 } else if (GenerateCode(&info)) { 1079 } else if (GenerateCode(&info)) {
1079 ASSERT(!info.code().is_null()); 1080 ASSERT(!info.code().is_null());
1080 scope_info = ScopeInfo::Create(info.scope(), info.zone()); 1081 scope_info = ScopeInfo::Create(info.scope(), info.zone());
1081 } else { 1082 } else {
1082 return Handle<SharedFunctionInfo>::null(); 1083 return Handle<SharedFunctionInfo>::null();
1083 } 1084 }
1084 1085
1085 // Create a shared function info object. 1086 // Create a shared function info object.
1086 Handle<SharedFunctionInfo> result = 1087 Handle<SharedFunctionInfo> result =
1087 FACTORY->NewSharedFunctionInfo(literal->name(), 1088 factory->NewSharedFunctionInfo(literal->name(),
1088 literal->materialized_literal_count(), 1089 literal->materialized_literal_count(),
1089 literal->is_generator(), 1090 literal->is_generator(),
1090 info.code(), 1091 info.code(),
1091 scope_info); 1092 scope_info);
1092 SetFunctionInfo(result, literal, false, script); 1093 SetFunctionInfo(result, literal, false, script);
1093 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 1094 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
1094 result->set_allows_lazy_compilation(allow_lazy); 1095 result->set_allows_lazy_compilation(allow_lazy);
1095 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx); 1096 result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
1096 1097
1097 // Set the expected number of properties for instances and return 1098 // Set the expected number of properties for instances and return
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 } 1175 }
1175 } 1176 }
1176 1177
1177 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1178 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1178 Handle<Script>(info->script()), 1179 Handle<Script>(info->script()),
1179 Handle<Code>(info->code()), 1180 Handle<Code>(info->code()),
1180 info)); 1181 info));
1181 } 1182 }
1182 1183
1183 } } // namespace v8::internal 1184 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/d8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698