| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/compiler.h" | 5 #include "src/compiler.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <memory> | 8 #include <memory> | 
| 9 | 9 | 
| 10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" | 
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 170 // profiler, so they trigger their own optimization when they're called | 170 // profiler, so they trigger their own optimization when they're called | 
| 171 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 171 // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. | 
| 172 bool CompilationInfo::ShouldSelfOptimize() { | 172 bool CompilationInfo::ShouldSelfOptimize() { | 
| 173   return FLAG_crankshaft && | 173   return FLAG_crankshaft && | 
| 174          !(literal()->flags() & AstProperties::kDontSelfOptimize) && | 174          !(literal()->flags() & AstProperties::kDontSelfOptimize) && | 
| 175          !literal()->dont_optimize() && | 175          !literal()->dont_optimize() && | 
| 176          literal()->scope()->AllowsLazyCompilation() && | 176          literal()->scope()->AllowsLazyCompilation() && | 
| 177          !shared_info()->optimization_disabled(); | 177          !shared_info()->optimization_disabled(); | 
| 178 } | 178 } | 
| 179 | 179 | 
|  | 180 void CompilationInfo::ReopenHandlesInNewHandleScope() { | 
|  | 181   closure_ = Handle<JSFunction>(*closure_); | 
|  | 182 } | 
| 180 | 183 | 
| 181 bool CompilationInfo::has_simple_parameters() { | 184 bool CompilationInfo::has_simple_parameters() { | 
| 182   return scope()->has_simple_parameters(); | 185   return scope()->has_simple_parameters(); | 
| 183 } | 186 } | 
| 184 | 187 | 
| 185 std::unique_ptr<char[]> CompilationInfo::GetDebugName() const { | 188 std::unique_ptr<char[]> CompilationInfo::GetDebugName() const { | 
| 186   if (parse_info() && parse_info()->literal()) { | 189   if (parse_info() && parse_info()->literal()) { | 
| 187     AllowHandleDereference allow_deref; | 190     AllowHandleDereference allow_deref; | 
| 188     return parse_info()->literal()->debug_name()->ToCString(); | 191     return parse_info()->literal()->debug_name()->ToCString(); | 
| 189   } | 192   } | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 231 CompilationInfo::SourcePositionRecordingMode() const { | 234 CompilationInfo::SourcePositionRecordingMode() const { | 
| 232   return parse_info() && parse_info()->is_native() | 235   return parse_info() && parse_info()->is_native() | 
| 233              ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS | 236              ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS | 
| 234              : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS; | 237              : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS; | 
| 235 } | 238 } | 
| 236 | 239 | 
| 237 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { | 240 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { | 
| 238   return is_sloppy(parse_info()->language_mode()) && !parse_info()->is_native(); | 241   return is_sloppy(parse_info()->language_mode()) && !parse_info()->is_native(); | 
| 239 } | 242 } | 
| 240 | 243 | 
|  | 244 bool CompilationInfo::has_native_context() const { | 
|  | 245   return !closure().is_null() && (closure()->native_context() != nullptr); | 
|  | 246 } | 
|  | 247 | 
|  | 248 Context* CompilationInfo::native_context() const { | 
|  | 249   return has_native_context() ? closure()->native_context() : nullptr; | 
|  | 250 } | 
|  | 251 | 
|  | 252 bool CompilationInfo::has_global_object() const { return has_native_context(); } | 
|  | 253 | 
|  | 254 JSGlobalObject* CompilationInfo::global_object() const { | 
|  | 255   return has_global_object() ? native_context()->global_object() : nullptr; | 
|  | 256 } | 
|  | 257 | 
|  | 258 void CompilationInfo::AddInlinedFunction( | 
|  | 259     Handle<SharedFunctionInfo> inlined_function) { | 
|  | 260   inlined_functions_.push_back(InlinedFunctionHolder( | 
|  | 261       inlined_function, handle(inlined_function->code()))); | 
|  | 262 } | 
|  | 263 | 
|  | 264 Code::Kind CompilationInfo::output_code_kind() const { | 
|  | 265   return Code::ExtractKindFromFlags(code_flags_); | 
|  | 266 } | 
|  | 267 | 
| 241 // ---------------------------------------------------------------------------- | 268 // ---------------------------------------------------------------------------- | 
| 242 // Implementation of CompilationJob | 269 // Implementation of CompilationJob | 
| 243 | 270 | 
| 244 CompilationJob::Status CompilationJob::PrepareJob() { | 271 CompilationJob::Status CompilationJob::PrepareJob() { | 
| 245   DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id())); | 272   DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id())); | 
| 246   DisallowJavascriptExecution no_js(isolate()); | 273   DisallowJavascriptExecution no_js(isolate()); | 
| 247 | 274 | 
| 248   if (FLAG_trace_opt && info()->IsOptimizing()) { | 275   if (FLAG_trace_opt && info()->IsOptimizing()) { | 
| 249     OFStream os(stdout); | 276     OFStream os(stdout); | 
| 250     os << "[compiling method " << Brief(*info()->closure()) << " using " | 277     os << "[compiling method " << Brief(*info()->closure()) << " using " | 
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2048     DCHECK(shared->is_compiled()); | 2075     DCHECK(shared->is_compiled()); | 
| 2049     function->set_literals(cached.literals); | 2076     function->set_literals(cached.literals); | 
| 2050   } else if (shared->is_compiled()) { | 2077   } else if (shared->is_compiled()) { | 
| 2051     // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 2078     // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 
| 2052     JSFunction::EnsureLiterals(function); | 2079     JSFunction::EnsureLiterals(function); | 
| 2053   } | 2080   } | 
| 2054 } | 2081 } | 
| 2055 | 2082 | 
| 2056 }  // namespace internal | 2083 }  // namespace internal | 
| 2057 }  // namespace v8 | 2084 }  // namespace v8 | 
| OLD | NEW | 
|---|