sgjesse@chromium.org | df7a284 | 2010-03-25 14:34:15 +0000 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
ricow@chromium.org | eb7c144 | 2010-10-04 08:54:21 +0000 | [diff] [blame] | 30 | #include "compiler.h" |
| 31 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 32 | #include "bootstrapper.h" |
| 33 | #include "codegen-inl.h" |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 34 | #include "compilation-cache.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 35 | #include "data-flow.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 36 | #include "debug.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 37 | #include "full-codegen.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 38 | #include "liveedit.h" |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 39 | #include "oprofile-agent.h" |
ricow@chromium.org | eb7c144 | 2010-10-04 08:54:21 +0000 | [diff] [blame] | 40 | #include "parser.h" |
ager@chromium.org | 71daaf6 | 2009-04-01 07:22:49 +0000 | [diff] [blame] | 41 | #include "rewriter.h" |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 42 | #include "scopeinfo.h" |
ricow@chromium.org | eb7c144 | 2010-10-04 08:54:21 +0000 | [diff] [blame] | 43 | #include "scopes.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 45 | namespace v8 { |
| 46 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 47 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 48 | |
| 49 | CompilationInfo::CompilationInfo(Handle<Script> script) |
| 50 | : flags_(0), |
| 51 | function_(NULL), |
| 52 | scope_(NULL), |
| 53 | script_(script), |
| 54 | extension_(NULL), |
| 55 | pre_parse_data_(NULL) { |
| 56 | } |
| 57 | |
| 58 | |
| 59 | CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info) |
| 60 | : flags_(IsLazy::encode(true)), |
| 61 | function_(NULL), |
| 62 | scope_(NULL), |
| 63 | shared_info_(shared_info), |
| 64 | script_(Handle<Script>(Script::cast(shared_info->script()))), |
| 65 | extension_(NULL), |
| 66 | pre_parse_data_(NULL) { |
| 67 | } |
| 68 | |
| 69 | |
| 70 | CompilationInfo::CompilationInfo(Handle<JSFunction> closure) |
| 71 | : flags_(IsLazy::encode(true)), |
| 72 | function_(NULL), |
| 73 | scope_(NULL), |
| 74 | closure_(closure), |
| 75 | shared_info_(Handle<SharedFunctionInfo>(closure->shared())), |
| 76 | script_(Handle<Script>(Script::cast(shared_info_->script()))), |
| 77 | extension_(NULL), |
| 78 | pre_parse_data_(NULL) { |
| 79 | } |
| 80 | |
| 81 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 82 | // For normal operation the syntax checker is used to determine whether to |
| 83 | // use the full compiler for top level code or not. However if the flag |
| 84 | // --always-full-compiler is specified or debugging is active the full |
| 85 | // compiler will be used for all code. |
| 86 | static bool AlwaysFullCompiler() { |
| 87 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 88 | return FLAG_always_full_compiler || Debugger::IsDebuggerActive(); |
| 89 | #else |
| 90 | return FLAG_always_full_compiler; |
| 91 | #endif |
| 92 | } |
| 93 | |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 94 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 95 | static bool MakeCode(CompilationInfo* info) { |
| 96 | // Precondition: code has been parsed. Postcondition: the code field in |
| 97 | // the compilation info is set if compilation succeeded. |
| 98 | ASSERT(info->function() != NULL); |
| 99 | |
| 100 | if (Rewriter::Rewrite(info) && |
| 101 | Scope::Analyze(info) && |
| 102 | Rewriter::Analyze(info)) { |
| 103 | // Generate code and return it. Code generator selection is governed by |
| 104 | // which backends are enabled and whether the function is considered |
| 105 | // run-once code or not. |
| 106 | // |
| 107 | // --full-compiler enables the dedicated backend for code we expect to |
| 108 | // be run once |
| 109 | // |
| 110 | // The normal choice of backend can be overridden with the flags |
| 111 | // --always-full-compiler. |
| 112 | Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 113 | bool is_run_once = (shared.is_null()) |
| 114 | ? info->scope()->is_global_scope() |
| 115 | : (shared->is_toplevel() || shared->try_full_codegen()); |
| 116 | bool can_use_full = |
| 117 | FLAG_full_compiler && !info->function()->contains_loops(); |
| 118 | if (AlwaysFullCompiler() || (is_run_once && can_use_full)) { |
| 119 | return FullCodeGenerator::MakeCode(info); |
| 120 | } else { |
| 121 | AssignedVariablesAnalyzer ava; |
| 122 | return ava.Analyze(info) && CodeGenerator::MakeCode(info); |
| 123 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 124 | } |
| 125 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 126 | return false; |
ager@chromium.org | 3a37e9b | 2009-04-27 09:26:21 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 130 | #ifdef ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 131 | bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) { |
| 132 | // Precondition: code has been parsed. Postcondition: the code field in |
| 133 | // the compilation info is set if compilation succeeded. |
| 134 | bool succeeded = MakeCode(info); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 135 | if (!info->shared_info().is_null()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 136 | Handle<SerializedScopeInfo> scope_info = |
| 137 | SerializedScopeInfo::Create(info->scope()); |
| 138 | info->shared_info()->set_scope_info(*scope_info); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 139 | } |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 140 | return succeeded; |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 141 | } |
| 142 | #endif |
| 143 | |
| 144 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 145 | static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 146 | CompilationZoneScope zone_scope(DELETE_ON_EXIT); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 147 | |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 148 | PostponeInterruptsScope postpone; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 149 | |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 150 | ASSERT(!i::Top::global_context().is_null()); |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 151 | Handle<Script> script = info->script(); |
ager@chromium.org | 9085a01 | 2009-05-11 19:22:57 +0000 | [diff] [blame] | 152 | script->set_context_data((*i::Top::global_context())->data()); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 153 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 154 | #ifdef ENABLE_DEBUGGER_SUPPORT |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 155 | if (info->is_eval()) { |
| 156 | Script::CompilationType compilation_type = Script::COMPILATION_TYPE_EVAL; |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 157 | script->set_compilation_type(Smi::FromInt(compilation_type)); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 158 | // For eval scripts add information on the function from which eval was |
| 159 | // called. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 160 | if (info->is_eval()) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 161 | StackTraceFrameIterator it; |
| 162 | if (!it.done()) { |
| 163 | script->set_eval_from_shared( |
| 164 | JSFunction::cast(it.frame()->function())->shared()); |
| 165 | int offset = static_cast<int>( |
| 166 | it.frame()->pc() - it.frame()->code()->instruction_start()); |
| 167 | script->set_eval_from_instructions_offset(Smi::FromInt(offset)); |
| 168 | } |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 172 | // Notify debugger |
| 173 | Debugger::OnBeforeCompile(script); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 174 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 175 | |
| 176 | // Only allow non-global compiles for eval. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 177 | ASSERT(info->is_eval() || info->is_global()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 178 | |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 179 | if (!ParserApi::Parse(info)) return Handle<SharedFunctionInfo>::null(); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 180 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 181 | // Measure how long it takes to do the compilation; only take the |
| 182 | // rest of the function into account to avoid overlap with the |
| 183 | // parsing statistics. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 184 | HistogramTimer* rate = info->is_eval() |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 185 | ? &Counters::compile_eval |
| 186 | : &Counters::compile; |
ager@chromium.org | bb29dc9 | 2009-03-24 13:25:23 +0000 | [diff] [blame] | 187 | HistogramTimerScope timer(rate); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 188 | |
| 189 | // Compile the code. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 190 | FunctionLiteral* lit = info->function(); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 191 | LiveEditFunctionTracker live_edit_tracker(lit); |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 192 | if (!MakeCode(info)) { |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 193 | Top::StackOverflow(); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 194 | return Handle<SharedFunctionInfo>::null(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 195 | } |
| 196 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 197 | ASSERT(!info->code().is_null()); |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 198 | if (script->name()->IsString()) { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 199 | PROFILE(CodeCreateEvent( |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 200 | info->is_eval() |
| 201 | ? Logger::EVAL_TAG |
| 202 | : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 203 | *info->code(), |
| 204 | String::cast(script->name()))); |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 205 | OPROFILE(CreateNativeCodeRegion(String::cast(script->name()), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 206 | info->code()->instruction_start(), |
| 207 | info->code()->instruction_size())); |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 208 | } else { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 209 | PROFILE(CodeCreateEvent( |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 210 | info->is_eval() |
| 211 | ? Logger::EVAL_TAG |
| 212 | : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), |
| 213 | *info->code(), |
| 214 | "")); |
| 215 | OPROFILE(CreateNativeCodeRegion(info->is_eval() ? "Eval" : "Script", |
| 216 | info->code()->instruction_start(), |
| 217 | info->code()->instruction_size())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | // Allocate function. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 221 | Handle<SharedFunctionInfo> result = |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 222 | Factory::NewSharedFunctionInfo( |
| 223 | lit->name(), |
| 224 | lit->materialized_literal_count(), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 225 | info->code(), |
| 226 | SerializedScopeInfo::Create(info->scope())); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 227 | |
sgjesse@chromium.org | 911335c | 2009-08-19 12:59:44 +0000 | [diff] [blame] | 228 | ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 229 | Compiler::SetFunctionInfo(result, lit, true, script); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 230 | |
| 231 | // Hint to the runtime system used when allocating space for initial |
| 232 | // property space by setting the expected number of properties for |
| 233 | // the instances of the function. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 234 | SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 235 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 236 | #ifdef ENABLE_DEBUGGER_SUPPORT |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 237 | // Notify debugger |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 238 | Debugger::OnAfterCompile(script, Debugger::NO_AFTER_COMPILE_FLAGS); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 239 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 240 | |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 241 | live_edit_tracker.RecordFunctionInfo(result, lit); |
| 242 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 243 | return result; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 247 | Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, |
| 248 | Handle<Object> script_name, |
| 249 | int line_offset, |
| 250 | int column_offset, |
| 251 | v8::Extension* extension, |
| 252 | ScriptDataImpl* input_pre_data, |
| 253 | Handle<Object> script_data, |
| 254 | NativesFlag natives) { |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 255 | int source_length = source->length(); |
| 256 | Counters::total_load_size.Increment(source_length); |
| 257 | Counters::total_compile_size.Increment(source_length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 258 | |
| 259 | // The VM is in the COMPILER state until exiting this function. |
| 260 | VMState state(COMPILER); |
| 261 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 262 | // Do a lookup in the compilation cache but not for extensions. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 263 | Handle<SharedFunctionInfo> result; |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 264 | if (extension == NULL) { |
| 265 | result = CompilationCache::LookupScript(source, |
| 266 | script_name, |
| 267 | line_offset, |
| 268 | column_offset); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 269 | } |
| 270 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 271 | if (result.is_null()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 272 | // No cache entry found. Do pre-parsing, if it makes sense, and compile |
| 273 | // the script. |
| 274 | // Building preparse data that is only used immediately after is only a |
| 275 | // saving if we might skip building the AST for lazily compiled functions. |
| 276 | // I.e., preparse data isn't relevant when the lazy flag is off, and |
| 277 | // for small sources, odds are that there aren't many functions |
| 278 | // that would be compiled lazily anyway, so we skip the preparse step |
| 279 | // in that case too. |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 280 | ScriptDataImpl* pre_data = input_pre_data; |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 281 | if (pre_data == NULL |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 282 | && source_length >= FLAG_min_preparse_length) { |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 283 | pre_data = ParserApi::PartialPreParse(source, NULL, extension); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | // Create a script object describing the script to be compiled. |
| 287 | Handle<Script> script = Factory::NewScript(source); |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 288 | if (natives == NATIVES_CODE) { |
| 289 | script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
| 290 | } |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 291 | if (!script_name.is_null()) { |
| 292 | script->set_name(*script_name); |
| 293 | script->set_line_offset(Smi::FromInt(line_offset)); |
| 294 | script->set_column_offset(Smi::FromInt(column_offset)); |
| 295 | } |
| 296 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 297 | script->set_data(script_data.is_null() ? Heap::undefined_value() |
| 298 | : *script_data); |
| 299 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 300 | // Compile the function and add it to the cache. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 301 | CompilationInfo info(script); |
| 302 | info.MarkAsGlobal(); |
| 303 | info.SetExtension(extension); |
| 304 | info.SetPreParseData(pre_data); |
| 305 | result = MakeFunctionInfo(&info); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 306 | if (extension == NULL && !result.is_null()) { |
kasperl@chromium.org | 8ccb0be | 2009-04-07 07:21:39 +0000 | [diff] [blame] | 307 | CompilationCache::PutScript(source, result); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | // Get rid of the pre-parsing data (if necessary). |
| 311 | if (input_pre_data == NULL && pre_data != NULL) { |
| 312 | delete pre_data; |
| 313 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 314 | } |
| 315 | |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 316 | if (result.is_null()) Top::ReportPendingMessages(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 317 | return result; |
| 318 | } |
| 319 | |
| 320 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 321 | Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source, |
| 322 | Handle<Context> context, |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 323 | bool is_global) { |
ager@chromium.org | c3e50d8 | 2008-11-05 11:53:10 +0000 | [diff] [blame] | 324 | int source_length = source->length(); |
ager@chromium.org | 870a0b6 | 2008-11-04 11:43:05 +0000 | [diff] [blame] | 325 | Counters::total_eval_size.Increment(source_length); |
| 326 | Counters::total_compile_size.Increment(source_length); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 327 | |
| 328 | // The VM is in the COMPILER state until exiting this function. |
| 329 | VMState state(COMPILER); |
| 330 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 331 | // Do a lookup in the compilation cache; if the entry is not there, invoke |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 332 | // the compiler and add the result to the cache. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 333 | Handle<SharedFunctionInfo> result; |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 334 | result = CompilationCache::LookupEval(source, context, is_global); |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 335 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 336 | if (result.is_null()) { |
| 337 | // Create a script object describing the script to be compiled. |
| 338 | Handle<Script> script = Factory::NewScript(source); |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 339 | CompilationInfo info(script); |
| 340 | info.MarkAsEval(); |
| 341 | if (is_global) info.MarkAsGlobal(); |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 342 | info.SetCallingContext(context); |
| 343 | result = MakeFunctionInfo(&info); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 344 | if (!result.is_null()) { |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 345 | CompilationCache::PutEval(source, context, is_global, result); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 346 | } |
| 347 | } |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 348 | |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 349 | return result; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 353 | bool Compiler::CompileLazy(CompilationInfo* info) { |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 354 | CompilationZoneScope zone_scope(DELETE_ON_EXIT); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 355 | |
| 356 | // The VM is in the COMPILER state until exiting this function. |
| 357 | VMState state(COMPILER); |
| 358 | |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 359 | PostponeInterruptsScope postpone; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 360 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 361 | Handle<SharedFunctionInfo> shared = info->shared_info(); |
kmillikin@chromium.org | f05f291 | 2010-09-30 10:07:24 +0000 | [diff] [blame] | 362 | int compiled_size = shared->end_position() - shared->start_position(); |
| 363 | Counters::total_compile_size.Increment(compiled_size); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 364 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 365 | // Generate the AST for the lazily compiled function. |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 366 | if (ParserApi::Parse(info)) { |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 367 | // Measure how long it takes to do the lazy compilation; only take the |
| 368 | // rest of the function into account to avoid overlap with the lazy |
| 369 | // parsing statistics. |
| 370 | HistogramTimerScope timer(&Counters::compile_lazy); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 371 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 372 | // Compile the code. |
| 373 | if (!MakeCode(info)) { |
| 374 | Top::StackOverflow(); |
| 375 | } else { |
| 376 | ASSERT(!info->code().is_null()); |
| 377 | RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, |
| 378 | Handle<String>(shared->DebugName()), |
| 379 | shared->start_position(), |
| 380 | info); |
kasper.lund | 212ac23 | 2008-07-16 07:07:30 +0000 | [diff] [blame] | 381 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 382 | // Update the shared function info with the compiled code and the |
| 383 | // scope info. Please note, that the order of the sharedfunction |
| 384 | // initialization is important since SerializedScopeInfo::Create might |
| 385 | // trigger a GC, causing the ASSERT below to be invalid if the code |
| 386 | // was flushed. By setting the code object last we avoid this. |
| 387 | Handle<SerializedScopeInfo> scope_info = |
| 388 | SerializedScopeInfo::Create(info->scope()); |
| 389 | shared->set_scope_info(*scope_info); |
| 390 | shared->set_code(*info->code()); |
| 391 | if (!info->closure().is_null()) { |
| 392 | info->closure()->set_code(*info->code()); |
| 393 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 394 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 395 | // Set the expected number of properties for instances. |
| 396 | FunctionLiteral* lit = info->function(); |
| 397 | SetExpectedNofPropertiesFromEstimate(shared, |
| 398 | lit->expected_property_count()); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 399 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 400 | // Set the optimization hints after performing lazy compilation, as |
| 401 | // these are not set when the function is set up as a lazily compiled |
| 402 | // function. |
| 403 | shared->SetThisPropertyAssignmentsInfo( |
| 404 | lit->has_only_simple_this_property_assignments(), |
| 405 | *lit->this_property_assignments()); |
| 406 | |
| 407 | // Check the function has compiled code. |
| 408 | ASSERT(shared->is_compiled()); |
| 409 | shared->set_code_age(0); |
| 410 | ASSERT(!info->code().is_null()); |
| 411 | return true; |
| 412 | } |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 413 | } |
| 414 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 415 | ASSERT(info->code().is_null()); |
| 416 | return false; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 420 | Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal, |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 421 | Handle<Script> script) { |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 422 | #ifdef DEBUG |
| 423 | // We should not try to compile the same function literal more than |
| 424 | // once. |
| 425 | literal->mark_as_compiled(); |
| 426 | #endif |
| 427 | |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 428 | // Precondition: code has been parsed and scopes have been analyzed. |
| 429 | CompilationInfo info(script); |
| 430 | info.SetFunction(literal); |
| 431 | info.SetScope(literal->scope()); |
| 432 | |
| 433 | LiveEditFunctionTracker live_edit_tracker(literal); |
| 434 | // Determine if the function can be lazily compiled. This is necessary to |
| 435 | // allow some of our builtin JS files to be lazily compiled. These |
| 436 | // builtins cannot be handled lazily by the parser, since we have to know |
| 437 | // if a function uses the special natives syntax, which is something the |
| 438 | // parser records. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 439 | bool allow_lazy = literal->AllowsLazyCompilation() && |
| 440 | !LiveEditFunctionTracker::IsActive(); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 441 | |
ager@chromium.org | b573749 | 2010-07-15 09:29:43 +0000 | [diff] [blame] | 442 | Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty()); |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 443 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 444 | // Generate code |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 445 | if (FLAG_lazy && allow_lazy) { |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 446 | Handle<Code> code(Builtins::builtin(Builtins::LazyCompile)); |
| 447 | info.SetCode(code); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 448 | } else { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 449 | // Generate code and return it. The way that the compilation mode |
| 450 | // is controlled by the command-line flags is described in |
| 451 | // the static helper function MakeCode. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 452 | // |
| 453 | // The bodies of function literals have not yet been visited by |
| 454 | // the AST analyzer. |
| 455 | if (!Rewriter::Analyze(&info)) return Handle<SharedFunctionInfo>::null(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 456 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 457 | bool is_run_once = literal->try_full_codegen(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 458 | bool use_full = FLAG_full_compiler && !literal->contains_loops(); |
| 459 | if (AlwaysFullCompiler() || (use_full && is_run_once)) { |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 460 | if (!FullCodeGenerator::MakeCode(&info)) { |
| 461 | return Handle<SharedFunctionInfo>::null(); |
| 462 | } |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 463 | } else { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 464 | // We fall back to the classic V8 code generator. |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 465 | AssignedVariablesAnalyzer ava; |
| 466 | if (!ava.Analyze(&info)) return Handle<SharedFunctionInfo>::null(); |
| 467 | if (!CodeGenerator::MakeCode(&info)) { |
| 468 | return Handle<SharedFunctionInfo>::null(); |
| 469 | } |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | // Function compilation complete. |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 473 | RecordFunctionCompilation(Logger::FUNCTION_TAG, |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 474 | literal->debug_name(), |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 475 | literal->start_position(), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 476 | &info); |
ager@chromium.org | b573749 | 2010-07-15 09:29:43 +0000 | [diff] [blame] | 477 | scope_info = SerializedScopeInfo::Create(info.scope()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 478 | } |
| 479 | |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 480 | // Create a shared function info object. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 481 | Handle<SharedFunctionInfo> result = |
| 482 | Factory::NewSharedFunctionInfo(literal->name(), |
| 483 | literal->materialized_literal_count(), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 484 | info.code(), |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 485 | scope_info); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 486 | SetFunctionInfo(result, literal, false, script); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 487 | |
| 488 | // Set the expected number of properties for instances and return |
| 489 | // the resulting function. |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 490 | SetExpectedNofPropertiesFromEstimate(result, |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 491 | literal->expected_property_count()); |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 492 | live_edit_tracker.RecordFunctionInfo(result, literal); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 493 | return result; |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | |
| 497 | // Sets the function info on a function. |
| 498 | // The start_position points to the first '(' character after the function name |
| 499 | // in the full script source. When counting characters in the script source the |
| 500 | // the first character is number 0 (not 1). |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 501 | void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 502 | FunctionLiteral* lit, |
| 503 | bool is_toplevel, |
| 504 | Handle<Script> script) { |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 505 | function_info->set_length(lit->num_parameters()); |
| 506 | function_info->set_formal_parameter_count(lit->num_parameters()); |
| 507 | function_info->set_script(*script); |
| 508 | function_info->set_function_token_position(lit->function_token_position()); |
| 509 | function_info->set_start_position(lit->start_position()); |
| 510 | function_info->set_end_position(lit->end_position()); |
| 511 | function_info->set_is_expression(lit->is_expression()); |
| 512 | function_info->set_is_toplevel(is_toplevel); |
| 513 | function_info->set_inferred_name(*lit->inferred_name()); |
| 514 | function_info->SetThisPropertyAssignmentsInfo( |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 515 | lit->has_only_simple_this_property_assignments(), |
| 516 | *lit->this_property_assignments()); |
kmillikin@chromium.org | 5d8f0e6 | 2010-03-24 08:21:20 +0000 | [diff] [blame] | 517 | function_info->set_try_full_codegen(lit->try_full_codegen()); |
vegorov@chromium.org | 2356e6f | 2010-06-09 09:38:56 +0000 | [diff] [blame] | 518 | function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 522 | void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag, |
| 523 | Handle<String> name, |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 524 | int start_position, |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 525 | CompilationInfo* info) { |
| 526 | // Log the code generation. If source information is available include |
| 527 | // script name and line number. Check explicitly whether logging is |
| 528 | // enabled as finding the line number is not free. |
| 529 | if (Logger::is_logging() || |
| 530 | OProfileAgent::is_enabled() || |
| 531 | CpuProfiler::is_profiling()) { |
| 532 | Handle<Script> script = info->script(); |
| 533 | Handle<Code> code = info->code(); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 534 | if (script->name()->IsString()) { |
| 535 | int line_num = GetScriptLineNumber(script, start_position) + 1; |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 536 | USE(line_num); |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 537 | PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 538 | *code, |
| 539 | *name, |
| 540 | String::cast(script->name()), |
| 541 | line_num)); |
| 542 | OPROFILE(CreateNativeCodeRegion(*name, |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 543 | String::cast(script->name()), |
| 544 | line_num, |
| 545 | code->instruction_start(), |
| 546 | code->instruction_size())); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 547 | } else { |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 548 | PROFILE(CodeCreateEvent(Logger::ToNativeByScript(tag, *script), |
ager@chromium.org | b61a0d1 | 2010-10-13 08:35:23 +0000 | [diff] [blame] | 549 | *code, |
| 550 | *name)); |
| 551 | OPROFILE(CreateNativeCodeRegion(*name, |
ager@chromium.org | b26c50a | 2010-03-26 09:27:16 +0000 | [diff] [blame] | 552 | code->instruction_start(), |
| 553 | code->instruction_size())); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 554 | } |
| 555 | } |
| 556 | } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 557 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 558 | } } // namespace v8::internal |