Refactor bailout reasons and disable optimization in more cases.
authoryangguo@chromium.org <yangguo@chromium.org>
Wed, 24 Sep 2014 07:08:27 +0000 (07:08 +0000)
committeryangguo@chromium.org <yangguo@chromium.org>
Wed, 24 Sep 2014 07:08:27 +0000 (07:08 +0000)
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/596783002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24161 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

34 files changed:
BUILD.gn
src/arm/lithium-arm.cc
src/arm/lithium-arm.h
src/arm/macro-assembler-arm.h
src/arm64/lithium-arm64.cc
src/arm64/lithium-arm64.h
src/arm64/macro-assembler-arm64.h
src/ast.h
src/bailout-reason.cc [new file with mode: 0644]
src/bailout-reason.h [new file with mode: 0644]
src/code-stubs-hydrogen.cc
src/compiler.cc
src/compiler.h
src/compiler/pipeline.cc
src/hydrogen.cc
src/hydrogen.h
src/ia32/lithium-ia32.cc
src/ia32/lithium-ia32.h
src/ia32/macro-assembler-ia32.h
src/lithium-codegen.cc
src/lithium-codegen.h
src/lithium.cc
src/lithium.h
src/log.cc
src/objects.cc
src/objects.h
src/optimizing-compiler-thread.cc
src/parser.cc
src/preparser.h
src/runtime.cc
src/x64/lithium-x64.cc
src/x64/lithium-x64.h
src/x64/macro-assembler-x64.h
tools/gyp/v8.gyp

index 81de8f9cf16b16a60b42e47337134097b04c8b9e..315c203661c897773f67079bfd014f651b16937e 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -438,6 +438,8 @@ source_set("v8_base") {
     "src/ast.h",
     "src/background-parsing-task.cc",
     "src/background-parsing-task.h",
+    "src/bailout-reason.cc",
+    "src/bailout-reason.h",
     "src/bignum-dtoa.cc",
     "src/bignum-dtoa.h",
     "src/bignum.cc",
index 9db5bd6678777d5e0e4cab41d44a76183876a201..13a46a2b54b2f4ec0b9a35da635e57eccf3585ec 100644 (file)
@@ -423,12 +423,6 @@ LPlatformChunk* LChunkBuilder::Build() {
 }
 
 
-void LChunkBuilder::Abort(BailoutReason reason) {
-  info()->set_bailout_reason(reason);
-  status_ = ABORTED;
-}
-
-
 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
   return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
                                   Register::ToAllocationIndex(reg));
@@ -2476,7 +2470,7 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
   } else {
     spill_index = env_index - instr->environment()->first_local_index();
     if (spill_index > LUnallocated::kMaxFixedSlotIndex) {
-      Abort(kTooManySpillSlotsNeededForOSR);
+      Retry(kTooManySpillSlotsNeededForOSR);
       spill_index = 0;
     }
   }
index 1d0ce1571a7c20b8b0d8a821940f6cea7da69f0f..f9feaf6de28ecab9453f20c19da8a130b67102ea 100644 (file)
@@ -2758,17 +2758,11 @@ class LPlatformChunk FINAL : public LChunk {
 class LChunkBuilder FINAL : public LChunkBuilderBase {
  public:
   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
-      : LChunkBuilderBase(graph->zone()),
-        chunk_(NULL),
-        info_(info),
-        graph_(graph),
-        status_(UNUSED),
+      : LChunkBuilderBase(info, graph),
         current_instruction_(NULL),
         current_block_(NULL),
         next_block_(NULL),
-        allocator_(allocator) { }
-
-  Isolate* isolate() const { return graph_->isolate(); }
+        allocator_(allocator) {}
 
   // Build the sequence for the graph.
   LPlatformChunk* Build();
@@ -2804,24 +2798,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
 
  private:
-  enum Status {
-    UNUSED,
-    BUILDING,
-    DONE,
-    ABORTED
-  };
-
-  LPlatformChunk* chunk() const { return chunk_; }
-  CompilationInfo* info() const { return info_; }
-  HGraph* graph() const { return graph_; }
-
-  bool is_unused() const { return status_ == UNUSED; }
-  bool is_building() const { return status_ == BUILDING; }
-  bool is_done() const { return status_ == DONE; }
-  bool is_aborted() const { return status_ == ABORTED; }
-
-  void Abort(BailoutReason reason);
-
   // Methods for getting operands for Use / Define / Temp.
   LUnallocated* ToUnallocated(Register reg);
   LUnallocated* ToUnallocated(DoubleRegister reg);
@@ -2906,10 +2882,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   LInstruction* DoArithmeticT(Token::Value op,
                               HBinaryOperation* instr);
 
-  LPlatformChunk* chunk_;
-  CompilationInfo* info_;
-  HGraph* const graph_;
-  Status status_;
   HInstruction* current_instruction_;
   HBasicBlock* current_block_;
   HBasicBlock* next_block_;
index 030b87a0da2e75e7d4ea9776df32ba03cb6e0d42..d2a178664e0f18796e422670050a30e73ad76ec3 100644 (file)
@@ -6,6 +6,7 @@
 #define V8_ARM_MACRO_ASSEMBLER_ARM_H_
 
 #include "src/assembler.h"
+#include "src/bailout-reason.h"
 #include "src/frames.h"
 #include "src/globals.h"
 
index b15b414bfb0b718371dbd8ec4bcde2a08286ca5b..237714c86469df2835e9f63642bc4d3d09dcf6e4 100644 (file)
@@ -354,12 +354,6 @@ const char* LArithmeticT::Mnemonic() const {
 }
 
 
-void LChunkBuilder::Abort(BailoutReason reason) {
-  info()->set_bailout_reason(reason);
-  status_ = ABORTED;
-}
-
-
 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
   return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
                                   Register::ToAllocationIndex(reg));
@@ -2689,7 +2683,7 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
   } else {
     spill_index = env_index - instr->environment()->first_local_index();
     if (spill_index > LUnallocated::kMaxFixedSlotIndex) {
-      Abort(kTooManySpillSlotsNeededForOSR);
+      Retry(kTooManySpillSlotsNeededForOSR);
       spill_index = 0;
     }
   }
index 2a64d0635aee3e3c85c67b7dfa2c697384545157..82b6e50c08077efcb6d1e747c685e31f8ad5f274 100644 (file)
@@ -3097,14 +3097,10 @@ class LPlatformChunk FINAL : public LChunk {
 class LChunkBuilder FINAL : public LChunkBuilderBase {
  public:
   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
-      : LChunkBuilderBase(graph->zone()),
-        chunk_(NULL),
-        info_(info),
-        graph_(graph),
-        status_(UNUSED),
+      : LChunkBuilderBase(info, graph),
         current_instruction_(NULL),
         current_block_(NULL),
-        allocator_(allocator) { }
+        allocator_(allocator) {}
 
   // Build the sequence for the graph.
   LPlatformChunk* Build();
@@ -3127,27 +3123,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   static bool HasMagicNumberForDivision(int32_t divisor);
 
  private:
-  enum Status {
-    UNUSED,
-    BUILDING,
-    DONE,
-    ABORTED
-  };
-
-  HGraph* graph() const { return graph_; }
-  Isolate* isolate() const { return info_->isolate(); }
-
-  bool is_unused() const { return status_ == UNUSED; }
-  bool is_building() const { return status_ == BUILDING; }
-  bool is_done() const { return status_ == DONE; }
-  bool is_aborted() const { return status_ == ABORTED; }
-
-  int argument_count() const { return argument_count_; }
-  CompilationInfo* info() const { return info_; }
-  Heap* heap() const { return isolate()->heap(); }
-
-  void Abort(BailoutReason reason);
-
   // Methods for getting operands for Use / Define / Temp.
   LUnallocated* ToUnallocated(Register reg);
   LUnallocated* ToUnallocated(DoubleRegister reg);
@@ -3271,10 +3246,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   LInstruction* DoArithmeticT(Token::Value op,
                               HBinaryOperation* instr);
 
-  LPlatformChunk* chunk_;
-  CompilationInfo* info_;
-  HGraph* const graph_;
-  Status status_;
   HInstruction* current_instruction_;
   HBasicBlock* current_block_;
   LAllocator* allocator_;
index 33ef43927a4dbc90b32008027e5e210b6cec1cd7..d4593ac5998e33c786d08e80f79029d683af769a 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <vector>
 
+#include "src/bailout-reason.h"
 #include "src/globals.h"
 
 #include "src/arm64/assembler-arm64-inl.h"
index 03f1adf5ae086f6e4e73ddc09ca2cbe904b36b5c..03f43ad0a7aa4f8261c349da0244099e491bcf9d 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -9,6 +9,7 @@
 
 #include "src/assembler.h"
 #include "src/ast-value-factory.h"
+#include "src/bailout-reason.h"
 #include "src/factory.h"
 #include "src/feedback-slots.h"
 #include "src/interface.h"
diff --git a/src/bailout-reason.cc b/src/bailout-reason.cc
new file mode 100644 (file)
index 0000000..93d43dd
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/bailout-reason.h"
+#include "src/base/logging.h"
+
+namespace v8 {
+namespace internal {
+
+const char* GetBailoutReason(BailoutReason reason) {
+  DCHECK(reason < kLastErrorMessage);
+#define ERROR_MESSAGES_TEXTS(C, T) T,
+  static const char* error_messages_[] = {
+      ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)};
+#undef ERROR_MESSAGES_TEXTS
+  return error_messages_[reason];
+}
+}
+}  // namespace v8::internal
diff --git a/src/bailout-reason.h b/src/bailout-reason.h
new file mode 100644 (file)
index 0000000..7287d62
--- /dev/null
@@ -0,0 +1,339 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_BAILOUT_REASON_H_
+#define V8_BAILOUT_REASON_H_
+
+namespace v8 {
+namespace internal {
+
+#define ERROR_MESSAGES_LIST(V)                                                 \
+  V(kNoReason, "no reason")                                                    \
+                                                                               \
+  V(k32BitValueInRegisterIsNotZeroExtended,                                    \
+    "32 bit value in register is not zero-extended")                           \
+  V(kAlignmentMarkerExpected, "Alignment marker expected")                     \
+  V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned")         \
+  V(kAPICallReturnedInvalidObject, "API call returned invalid object")         \
+  V(kArgumentsObjectValueInATestContext,                                       \
+    "Arguments object value in a test context")                                \
+  V(kArrayBoilerplateCreationFailed, "Array boilerplate creation failed")      \
+  V(kArrayIndexConstantValueTooBig, "Array index constant value too big")      \
+  V(kAssignmentToArguments, "Assignment to arguments")                         \
+  V(kAssignmentToLetVariableBeforeInitialization,                              \
+    "Assignment to let variable before initialization")                        \
+  V(kAssignmentToLOOKUPVariable, "Assignment to LOOKUP variable")              \
+  V(kAssignmentToParameterFunctionUsesArgumentsObject,                         \
+    "Assignment to parameter, function uses arguments object")                 \
+  V(kAssignmentToParameterInArgumentsObject,                                   \
+    "Assignment to parameter in arguments object")                             \
+  V(kAttemptToUseUndefinedCache, "Attempt to use undefined cache")             \
+  V(kBadValueContextForArgumentsObjectValue,                                   \
+    "Bad value context for arguments object value")                            \
+  V(kBadValueContextForArgumentsValue,                                         \
+    "Bad value context for arguments value")                                   \
+  V(kBailedOutDueToDependencyChange, "Bailed out due to dependency change")    \
+  V(kBailoutWasNotPrepared, "Bailout was not prepared")                        \
+  V(kBinaryStubGenerateFloatingPointCode,                                      \
+    "BinaryStub_GenerateFloatingPointCode")                                    \
+  V(kBothRegistersWereSmisInSelectNonSmi,                                      \
+    "Both registers were smis in SelectNonSmi")                                \
+  V(kCallToAJavaScriptRuntimeFunction,                                         \
+    "Call to a JavaScript runtime function")                                   \
+  V(kCannotTranslatePositionInChangedArea,                                     \
+    "Cannot translate position in changed area")                               \
+  V(kClassLiteral, "Class literal")                                            \
+  V(kCodeGenerationFailed, "Code generation failed")                           \
+  V(kCodeObjectNotProperlyPatched, "Code object not properly patched")         \
+  V(kCompoundAssignmentToLookupSlot, "Compound assignment to lookup slot")     \
+  V(kContextAllocatedArguments, "Context-allocated arguments")                 \
+  V(kCopyBuffersOverlap, "Copy buffers overlap")                               \
+  V(kCouldNotGenerateZero, "Could not generate +0.0")                          \
+  V(kCouldNotGenerateNegativeZero, "Could not generate -0.0")                  \
+  V(kDebuggerHasBreakPoints, "Debugger has break points")                      \
+  V(kDebuggerStatement, "DebuggerStatement")                                   \
+  V(kDeclarationInCatchContext, "Declaration in catch context")                \
+  V(kDeclarationInWithContext, "Declaration in with context")                  \
+  V(kDefaultNaNModeNotSet, "Default NaN mode not set")                         \
+  V(kDeleteWithGlobalVariable, "Delete with global variable")                  \
+  V(kDeleteWithNonGlobalVariable, "Delete with non-global variable")           \
+  V(kDestinationOfCopyNotAligned, "Destination of copy not aligned")           \
+  V(kDontDeleteCellsCannotContainTheHole,                                      \
+    "DontDelete cells can't contain the hole")                                 \
+  V(kDoPushArgumentNotImplementedForDoubleType,                                \
+    "DoPushArgument not implemented for double type")                          \
+  V(kEliminatedBoundsCheckFailed, "Eliminated bounds check failed")            \
+  V(kEmitLoadRegisterUnsupportedDoubleImmediate,                               \
+    "EmitLoadRegister: Unsupported double immediate")                          \
+  V(kEval, "eval")                                                             \
+  V(kExpected0AsASmiSentinel, "Expected 0 as a Smi sentinel")                  \
+  V(kExpectedAlignmentMarker, "Expected alignment marker")                     \
+  V(kExpectedAllocationSite, "Expected allocation site")                       \
+  V(kExpectedFunctionObject, "Expected function object in register")           \
+  V(kExpectedHeapNumber, "Expected HeapNumber")                                \
+  V(kExpectedNativeContext, "Expected native context")                         \
+  V(kExpectedNonIdenticalObjects, "Expected non-identical objects")            \
+  V(kExpectedNonNullContext, "Expected non-null context")                      \
+  V(kExpectedPositiveZero, "Expected +0.0")                                    \
+  V(kExpectedAllocationSiteInCell, "Expected AllocationSite in property cell") \
+  V(kExpectedFixedArrayInFeedbackVector,                                       \
+    "Expected fixed array in feedback vector")                                 \
+  V(kExpectedFixedArrayInRegisterA2, "Expected fixed array in register a2")    \
+  V(kExpectedFixedArrayInRegisterEbx, "Expected fixed array in register ebx")  \
+  V(kExpectedFixedArrayInRegisterR2, "Expected fixed array in register r2")    \
+  V(kExpectedFixedArrayInRegisterRbx, "Expected fixed array in register rbx")  \
+  V(kExpectedNewSpaceObject, "Expected new space object")                      \
+  V(kExpectedSmiOrHeapNumber, "Expected smi or HeapNumber")                    \
+  V(kExpectedUndefinedOrCell, "Expected undefined or cell in register")        \
+  V(kExpectingAlignmentForCopyBytes, "Expecting alignment for CopyBytes")      \
+  V(kExportDeclaration, "Export declaration")                                  \
+  V(kExternalStringExpectedButNotFound,                                        \
+    "External string expected, but not found")                                 \
+  V(kFailedBailedOutLastTime, "Failed/bailed out last time")                   \
+  V(kForInStatementIsNotFastCase, "ForInStatement is not fast case")           \
+  V(kForInStatementOptimizationIsDisabled,                                     \
+    "ForInStatement optimization is disabled")                                 \
+  V(kForInStatementWithNonLocalEachVariable,                                   \
+    "ForInStatement with non-local each variable")                             \
+  V(kForOfStatement, "ForOfStatement")                                         \
+  V(kFrameIsExpectedToBeAligned, "Frame is expected to be aligned")            \
+  V(kFunctionCallsEval, "Function calls eval")                                 \
+  V(kFunctionIsAGenerator, "Function is a generator")                          \
+  V(kFunctionWithIllegalRedeclaration, "Function with illegal redeclaration")  \
+  V(kGeneratedCodeIsTooLarge, "Generated code is too large")                   \
+  V(kGeneratorFailedToResume, "Generator failed to resume")                    \
+  V(kGenerator, "Generator")                                                   \
+  V(kGlobalFunctionsMustHaveInitialMap,                                        \
+    "Global functions must have initial map")                                  \
+  V(kHeapNumberMapRegisterClobbered, "HeapNumberMap register clobbered")       \
+  V(kHydrogenFilter, "Optimization disabled by filter")                        \
+  V(kImportDeclaration, "Import declaration")                                  \
+  V(kImproperObjectOnPrototypeChainForStore,                                   \
+    "Improper object on prototype chain for store")                            \
+  V(kIndexIsNegative, "Index is negative")                                     \
+  V(kIndexIsTooLarge, "Index is too large")                                    \
+  V(kInlinedRuntimeFunctionClassOf, "Inlined runtime function: ClassOf")       \
+  V(kInlinedRuntimeFunctionFastOneByteArrayJoin,                               \
+    "Inlined runtime function: FastOneByteArrayJoin")                          \
+  V(kInlinedRuntimeFunctionGeneratorNext,                                      \
+    "Inlined runtime function: GeneratorNext")                                 \
+  V(kInlinedRuntimeFunctionGeneratorThrow,                                     \
+    "Inlined runtime function: GeneratorThrow")                                \
+  V(kInlinedRuntimeFunctionGetFromCache,                                       \
+    "Inlined runtime function: GetFromCache")                                  \
+  V(kInlinedRuntimeFunctionIsNonNegativeSmi,                                   \
+    "Inlined runtime function: IsNonNegativeSmi")                              \
+  V(kInlinedRuntimeFunctionIsStringWrapperSafeForDefaultValueOf,               \
+    "Inlined runtime function: IsStringWrapperSafeForDefaultValueOf")          \
+  V(kInliningBailedOut, "Inlining bailed out")                                 \
+  V(kInputGPRIsExpectedToHaveUpper32Cleared,                                   \
+    "Input GPR is expected to have upper32 cleared")                           \
+  V(kInputStringTooLong, "Input string too long")                              \
+  V(kInstanceofStubUnexpectedCallSiteCacheCheck,                               \
+    "InstanceofStub unexpected call site cache (check)")                       \
+  V(kInstanceofStubUnexpectedCallSiteCacheCmp1,                                \
+    "InstanceofStub unexpected call site cache (cmp 1)")                       \
+  V(kInstanceofStubUnexpectedCallSiteCacheCmp2,                                \
+    "InstanceofStub unexpected call site cache (cmp 2)")                       \
+  V(kInstanceofStubUnexpectedCallSiteCacheMov,                                 \
+    "InstanceofStub unexpected call site cache (mov)")                         \
+  V(kInteger32ToSmiFieldWritingToNonSmiLocation,                               \
+    "Integer32ToSmiField writing to non-smi location")                         \
+  V(kInvalidCaptureReferenced, "Invalid capture referenced")                   \
+  V(kInvalidElementsKindForInternalArrayOrInternalPackedArray,                 \
+    "Invalid ElementsKind for InternalArray or InternalPackedArray")           \
+  V(kInvalidFullCodegenState, "invalid full-codegen state")                    \
+  V(kInvalidHandleScopeLevel, "Invalid HandleScope level")                     \
+  V(kInvalidLeftHandSideInAssignment, "Invalid left-hand side in assignment")  \
+  V(kInvalidLhsInCompoundAssignment, "Invalid lhs in compound assignment")     \
+  V(kInvalidLhsInCountOperation, "Invalid lhs in count operation")             \
+  V(kInvalidMinLength, "Invalid min_length")                                   \
+  V(kJSGlobalObjectNativeContextShouldBeANativeContext,                        \
+    "JSGlobalObject::native_context should be a native context")               \
+  V(kJSGlobalProxyContextShouldNotBeNull,                                      \
+    "JSGlobalProxy::context() should not be null")                             \
+  V(kJSObjectWithFastElementsMapHasSlowElements,                               \
+    "JSObject with fast elements map has slow elements")                       \
+  V(kLetBindingReInitialization, "Let binding re-initialization")              \
+  V(kLhsHasBeenClobbered, "lhs has been clobbered")                            \
+  V(kLiveBytesCountOverflowChunkSize, "Live Bytes Count overflow chunk size")  \
+  V(kLiveEdit, "LiveEdit")                                                     \
+  V(kLookupVariableInCountOperation, "Lookup variable in count operation")     \
+  V(kMapBecameDeprecated, "Map became deprecated")                             \
+  V(kMapBecameUnstable, "Map became unstable")                                 \
+  V(kMapIsNoLongerInEax, "Map is no longer in eax")                            \
+  V(kModuleDeclaration, "Module declaration")                                  \
+  V(kModuleLiteral, "Module literal")                                          \
+  V(kModulePath, "Module path")                                                \
+  V(kModuleStatement, "Module statement")                                      \
+  V(kModuleVariable, "Module variable")                                        \
+  V(kModuleUrl, "Module url")                                                  \
+  V(kNativeFunctionLiteral, "Native function literal")                         \
+  V(kSuperReference, "Super reference")                                        \
+  V(kNeedSmiLiteral, "Need a Smi literal here")                                \
+  V(kNoCasesLeft, "No cases left")                                             \
+  V(kNoEmptyArraysHereInEmitFastOneByteArrayJoin,                              \
+    "No empty arrays here in EmitFastOneByteArrayJoin")                        \
+  V(kNonInitializerAssignmentToConst, "Non-initializer assignment to const")   \
+  V(kNonSmiIndex, "Non-smi index")                                             \
+  V(kNonSmiKeyInArrayLiteral, "Non-smi key in array literal")                  \
+  V(kNonSmiValue, "Non-smi value")                                             \
+  V(kNonObject, "Non-object value")                                            \
+  V(kNotEnoughVirtualRegistersForValues,                                       \
+    "Not enough virtual registers for values")                                 \
+  V(kNotEnoughSpillSlotsForOsr, "Not enough spill slots for OSR")              \
+  V(kNotEnoughVirtualRegistersRegalloc,                                        \
+    "Not enough virtual registers (regalloc)")                                 \
+  V(kObjectFoundInSmiOnlyArray, "Object found in smi-only array")              \
+  V(kObjectLiteralWithComplexProperty, "Object literal with complex property") \
+  V(kOddballInStringTableIsNotUndefinedOrTheHole,                              \
+    "Oddball in string table is not undefined or the hole")                    \
+  V(kOffsetOutOfRange, "Offset out of range")                                  \
+  V(kOperandIsASmiAndNotAName, "Operand is a smi and not a name")              \
+  V(kOperandIsASmiAndNotAString, "Operand is a smi and not a string")          \
+  V(kOperandIsASmi, "Operand is a smi")                                        \
+  V(kOperandIsNotAName, "Operand is not a name")                               \
+  V(kOperandIsNotANumber, "Operand is not a number")                           \
+  V(kOperandIsNotASmi, "Operand is not a smi")                                 \
+  V(kOperandIsNotAString, "Operand is not a string")                           \
+  V(kOperandIsNotSmi, "Operand is not smi")                                    \
+  V(kOperandNotANumber, "Operand not a number")                                \
+  V(kObjectTagged, "The object is tagged")                                     \
+  V(kObjectNotTagged, "The object is not tagged")                              \
+  V(kOptimizationDisabled, "Optimization is disabled")                         \
+  V(kOptimizedTooManyTimes, "Optimized too many times")                        \
+  V(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister,                   \
+    "Out of virtual registers while trying to allocate temp register")         \
+  V(kParseScopeError, "Parse/scope error")                                     \
+  V(kPossibleDirectCallToEval, "Possible direct call to eval")                 \
+  V(kPreconditionsWereNotMet, "Preconditions were not met")                    \
+  V(kPropertyAllocationCountFailed, "Property allocation count failed")        \
+  V(kReceivedInvalidReturnAddress, "Received invalid return address")          \
+  V(kReferenceToAVariableWhichRequiresDynamicLookup,                           \
+    "Reference to a variable which requires dynamic lookup")                   \
+  V(kReferenceToGlobalLexicalVariable, "Reference to global lexical variable") \
+  V(kReferenceToUninitializedVariable, "Reference to uninitialized variable")  \
+  V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root")  \
+  V(kRegisterWasClobbered, "Register was clobbered")                           \
+  V(kRememberedSetPointerInNewSpace, "Remembered set pointer is in new space") \
+  V(kReturnAddressNotFoundInFrame, "Return address not found in frame")        \
+  V(kRhsHasBeenClobbered, "Rhs has been clobbered")                            \
+  V(kScopedBlock, "ScopedBlock")                                               \
+  V(kSmiAdditionOverflow, "Smi addition overflow")                             \
+  V(kSmiSubtractionOverflow, "Smi subtraction overflow")                       \
+  V(kStackAccessBelowStackPointer, "Stack access below stack pointer")         \
+  V(kStackFrameTypesMustMatch, "Stack frame types must match")                 \
+  V(kTheCurrentStackPointerIsBelowCsp,                                         \
+    "The current stack pointer is below csp")                                  \
+  V(kTheInstructionShouldBeALui, "The instruction should be a lui")            \
+  V(kTheInstructionShouldBeAnOri, "The instruction should be an ori")          \
+  V(kTheInstructionToPatchShouldBeALoadFromConstantPool,                       \
+    "The instruction to patch should be a load from the constant pool")        \
+  V(kTheInstructionToPatchShouldBeAnLdrLiteral,                                \
+    "The instruction to patch should be a ldr literal")                        \
+  V(kTheInstructionToPatchShouldBeALui,                                        \
+    "The instruction to patch should be a lui")                                \
+  V(kTheInstructionToPatchShouldBeAnOri,                                       \
+    "The instruction to patch should be an ori")                               \
+  V(kTheSourceAndDestinationAreTheSame,                                        \
+    "The source and destination are the same")                                 \
+  V(kTheStackPointerIsNotAligned, "The stack pointer is not aligned.")         \
+  V(kTheStackWasCorruptedByMacroAssemblerCall,                                 \
+    "The stack was corrupted by MacroAssembler::Call()")                       \
+  V(kTooManyParametersLocals, "Too many parameters/locals")                    \
+  V(kTooManyParameters, "Too many parameters")                                 \
+  V(kTooManySpillSlotsNeededForOSR, "Too many spill slots needed for OSR")     \
+  V(kToOperand32UnsupportedImmediate, "ToOperand32 unsupported immediate.")    \
+  V(kToOperandIsDoubleRegisterUnimplemented,                                   \
+    "ToOperand IsDoubleRegister unimplemented")                                \
+  V(kToOperandUnsupportedDoubleImmediate,                                      \
+    "ToOperand Unsupported double immediate")                                  \
+  V(kTryCatchStatement, "TryCatchStatement")                                   \
+  V(kTryFinallyStatement, "TryFinallyStatement")                               \
+  V(kUnableToEncodeValueAsSmi, "Unable to encode value as smi")                \
+  V(kUnalignedAllocationInNewSpace, "Unaligned allocation in new space")       \
+  V(kUnalignedCellInWriteBarrier, "Unaligned cell in write barrier")           \
+  V(kUndefinedValueNotLoaded, "Undefined value not loaded")                    \
+  V(kUndoAllocationOfNonAllocatedMemory,                                       \
+    "Undo allocation of non allocated memory")                                 \
+  V(kUnexpectedAllocationTop, "Unexpected allocation top")                     \
+  V(kUnexpectedColorFound, "Unexpected color bit pattern found")               \
+  V(kUnexpectedElementsKindInArrayConstructor,                                 \
+    "Unexpected ElementsKind in array constructor")                            \
+  V(kUnexpectedFallthroughFromCharCodeAtSlowCase,                              \
+    "Unexpected fallthrough from CharCodeAt slow case")                        \
+  V(kUnexpectedFallthroughFromCharFromCodeSlowCase,                            \
+    "Unexpected fallthrough from CharFromCode slow case")                      \
+  V(kUnexpectedFallThroughFromStringComparison,                                \
+    "Unexpected fall-through from string comparison")                          \
+  V(kUnexpectedFallThroughInBinaryStubGenerateFloatingPointCode,               \
+    "Unexpected fall-through in BinaryStub_GenerateFloatingPointCode")         \
+  V(kUnexpectedFallthroughToCharCodeAtSlowCase,                                \
+    "Unexpected fallthrough to CharCodeAt slow case")                          \
+  V(kUnexpectedFallthroughToCharFromCodeSlowCase,                              \
+    "Unexpected fallthrough to CharFromCode slow case")                        \
+  V(kUnexpectedFPUStackDepthAfterInstruction,                                  \
+    "Unexpected FPU stack depth after instruction")                            \
+  V(kUnexpectedInitialMapForArrayFunction1,                                    \
+    "Unexpected initial map for Array function (1)")                           \
+  V(kUnexpectedInitialMapForArrayFunction2,                                    \
+    "Unexpected initial map for Array function (2)")                           \
+  V(kUnexpectedInitialMapForArrayFunction,                                     \
+    "Unexpected initial map for Array function")                               \
+  V(kUnexpectedInitialMapForInternalArrayFunction,                             \
+    "Unexpected initial map for InternalArray function")                       \
+  V(kUnexpectedLevelAfterReturnFromApiCall,                                    \
+    "Unexpected level after return from api call")                             \
+  V(kUnexpectedNegativeValue, "Unexpected negative value")                     \
+  V(kUnexpectedNumberOfPreAllocatedPropertyFields,                             \
+    "Unexpected number of pre-allocated property fields")                      \
+  V(kUnexpectedFPCRMode, "Unexpected FPCR mode.")                              \
+  V(kUnexpectedSmi, "Unexpected smi value")                                    \
+  V(kUnexpectedStringFunction, "Unexpected String function")                   \
+  V(kUnexpectedStringType, "Unexpected string type")                           \
+  V(kUnexpectedStringWrapperInstanceSize,                                      \
+    "Unexpected string wrapper instance size")                                 \
+  V(kUnexpectedTypeForRegExpDataFixedArrayExpected,                            \
+    "Unexpected type for RegExp data, FixedArray expected")                    \
+  V(kUnexpectedValue, "Unexpected value")                                      \
+  V(kUnexpectedUnusedPropertiesOfStringWrapper,                                \
+    "Unexpected unused properties of string wrapper")                          \
+  V(kUnimplemented, "unimplemented")                                           \
+  V(kUninitializedKSmiConstantRegister, "Uninitialized kSmiConstantRegister")  \
+  V(kUnknown, "Unknown")                                                       \
+  V(kUnsupportedConstCompoundAssignment,                                       \
+    "Unsupported const compound assignment")                                   \
+  V(kUnsupportedCountOperationWithConst,                                       \
+    "Unsupported count operation with const")                                  \
+  V(kUnsupportedDoubleImmediate, "Unsupported double immediate")               \
+  V(kUnsupportedLetCompoundAssignment, "Unsupported let compound assignment")  \
+  V(kUnsupportedLookupSlotInDeclaration,                                       \
+    "Unsupported lookup slot in declaration")                                  \
+  V(kUnsupportedNonPrimitiveCompare, "Unsupported non-primitive compare")      \
+  V(kUnsupportedPhiUseOfArguments, "Unsupported phi use of arguments")         \
+  V(kUnsupportedPhiUseOfConstVariable,                                         \
+    "Unsupported phi use of const variable")                                   \
+  V(kUnsupportedTaggedImmediate, "Unsupported tagged immediate")               \
+  V(kVariableResolvedToWithContext, "Variable resolved to with context")       \
+  V(kWeShouldNotHaveAnEmptyLexicalContext,                                     \
+    "We should not have an empty lexical context")                             \
+  V(kWithStatement, "WithStatement")                                           \
+  V(kWrongFunctionContext, "Wrong context passed to function")                 \
+  V(kWrongAddressOrValuePassedToRecordWrite,                                   \
+    "Wrong address or value passed to RecordWrite")                            \
+  V(kYield, "Yield")
+
+
+#define ERROR_MESSAGES_CONSTANTS(C, T) C,
+enum BailoutReason {
+  ERROR_MESSAGES_LIST(ERROR_MESSAGES_CONSTANTS) kLastErrorMessage
+};
+#undef ERROR_MESSAGES_CONSTANTS
+
+
+const char* GetBailoutReason(BailoutReason reason);
+}
+}  // namespace v8::internal
+
+#endif  // V8_BAILOUT_REASON_H_
index 1c43049cb746ad2b9068c765c49451344e112609..dafef522f1cd80d379922a6425e44ca2075f5f7e 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "src/v8.h"
 
+#include "src/bailout-reason.h"
 #include "src/code-stubs.h"
 #include "src/field-index.h"
 #include "src/hydrogen.h"
index 68918d684178ee9da67869e3424f820011912408..4331770644a3cfd5ca468dafff3f156d8c1d3639 100644 (file)
@@ -156,7 +156,6 @@ void CompilationInfo::Initialize(Isolate* isolate,
     return;
   }
   mode_ = mode;
-  abort_due_to_dependency_ = false;
   if (!script_.is_null() && script_->type()->value() == Script::TYPE_NATIVE) {
     MarkAsNative();
   }
@@ -169,7 +168,7 @@ void CompilationInfo::Initialize(Isolate* isolate,
     DCHECK(strict_mode() == SLOPPY);
     SetStrictMode(shared_info_->strict_mode());
   }
-  set_bailout_reason(kUnknown);
+  bailout_reason_ = kUnknown;
 
   if (!shared_info().is_null() && shared_info()->is_compiled()) {
     // We should initialize the CompilationInfo feedback vector from the
@@ -181,6 +180,9 @@ void CompilationInfo::Initialize(Isolate* isolate,
 
 
 CompilationInfo::~CompilationInfo() {
+  if (GetFlag(kDisableFutureOptimization)) {
+    shared_info()->DisableOptimization(bailout_reason());
+  }
   delete deferred_handles_;
   delete no_frame_ranges_;
   if (ast_value_factory_owned_) delete ast_value_factory_;
@@ -331,7 +333,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
 
   // Do not use crankshaft if we need to be able to set break points.
   if (isolate()->DebuggerHasBreakPoints()) {
-    return AbortOptimization(kDebuggerHasBreakPoints);
+    return RetryOptimization(kDebuggerHasBreakPoints);
   }
 
   // Limit the number of times we re-compile a functions with
@@ -339,7 +341,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
   const int kMaxOptCount =
       FLAG_deopt_every_n_times == 0 ? FLAG_max_opt_count : 1000;
   if (info()->opt_count() > kMaxOptCount) {
-    return AbortAndDisableOptimization(kOptimizedTooManyTimes);
+    return AbortOptimization(kOptimizedTooManyTimes);
   }
 
   // Due to an encoding limit on LUnallocated operands in the Lithium
@@ -352,17 +354,17 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
   const int parameter_limit = -LUnallocated::kMinFixedSlotIndex;
   Scope* scope = info()->scope();
   if ((scope->num_parameters() + 1) > parameter_limit) {
-    return AbortAndDisableOptimization(kTooManyParameters);
+    return AbortOptimization(kTooManyParameters);
   }
 
   const int locals_limit = LUnallocated::kMaxFixedSlotIndex;
   if (info()->is_osr() &&
       scope->num_parameters() + 1 + scope->num_stack_slots() > locals_limit) {
-    return AbortAndDisableOptimization(kTooManyParametersLocals);
+    return AbortOptimization(kTooManyParametersLocals);
   }
 
   if (scope->HasIllegalRedeclaration()) {
-    return AbortAndDisableOptimization(kFunctionWithIllegalRedeclaration);
+    return AbortOptimization(kFunctionWithIllegalRedeclaration);
   }
 
   // Check the whitelist for Crankshaft.
@@ -426,20 +428,11 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
     return SetLastStatus(FAILED);
   }
 
-  // The function being compiled may have bailed out due to an inline
-  // candidate bailing out.  In such a case, we don't disable
-  // optimization on the shared_info.
-  DCHECK(!graph_builder_->inline_bailout() || graph_ == NULL);
-  if (graph_ == NULL) {
-    if (graph_builder_->inline_bailout()) {
-      return AbortOptimization();
-    } else {
-      return AbortAndDisableOptimization();
-    }
-  }
+  if (graph_ == NULL) return SetLastStatus(BAILED_OUT);
 
   if (info()->HasAbortedDueToDependencyChange()) {
-    return AbortOptimization(kBailedOutDueToDependencyChange);
+    // Dependency has changed during graph creation. Let's try again later.
+    return RetryOptimization(kBailedOutDueToDependencyChange);
   }
 
   return SetLastStatus(SUCCEEDED);
@@ -469,7 +462,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::OptimizeGraph() {
     graph_builder_->Bailout(bailout_reason);
   }
 
-  return AbortOptimization();
+  return SetLastStatus(BAILED_OUT);
 }
 
 
@@ -496,23 +489,9 @@ OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() {
     Handle<Code> optimized_code = chunk_->Codegen();
     if (optimized_code.is_null()) {
       if (info()->bailout_reason() == kNoReason) {
-        info_->set_bailout_reason(kCodeGenerationFailed);
-      } else if (info()->bailout_reason() == kMapBecameDeprecated) {
-        if (FLAG_trace_opt) {
-          PrintF("[aborted optimizing ");
-          info()->closure()->ShortPrint();
-          PrintF(" because a map became deprecated]\n");
-        }
-        return AbortOptimization();
-      } else if (info()->bailout_reason() == kMapBecameUnstable) {
-        if (FLAG_trace_opt) {
-          PrintF("[aborted optimizing ");
-          info()->closure()->ShortPrint();
-          PrintF(" because a map became unstable]\n");
-        }
-        return AbortOptimization();
+        return AbortOptimization(kCodeGenerationFailed);
       }
-      return AbortAndDisableOptimization();
+      return SetLastStatus(BAILED_OUT);
     }
     info()->SetCode(optimized_code);
   }
@@ -764,15 +743,27 @@ static bool GetOptimizedCodeNow(CompilationInfo* info) {
   TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
 
   OptimizedCompileJob job(info);
-  if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false;
-  if (job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED) return false;
-  if (job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) return false;
+  if (job.CreateGraph() != OptimizedCompileJob::SUCCEEDED ||
+      job.OptimizeGraph() != OptimizedCompileJob::SUCCEEDED ||
+      job.GenerateCode() != OptimizedCompileJob::SUCCEEDED) {
+    if (FLAG_trace_opt) {
+      PrintF("[aborted optimizing ");
+      info->closure()->ShortPrint();
+      PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
+    }
+    return false;
+  }
 
   // Success!
   DCHECK(!info->isolate()->has_pending_exception());
   InsertCodeIntoOptimizedCodeMap(info);
   RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info,
                             info->shared_info());
+  if (FLAG_trace_opt) {
+    PrintF("[completed optimizing ");
+    info->closure()->ShortPrint();
+    PrintF("]\n");
+  }
   return true;
 }
 
@@ -782,7 +773,7 @@ static bool GetOptimizedCodeLater(CompilationInfo* info) {
   if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
     if (FLAG_trace_concurrent_recompilation) {
       PrintF("  ** Compilation queue full, will retry optimizing ");
-      info->closure()->PrintName();
+      info->closure()->ShortPrint();
       PrintF(" later.\n");
     }
     return false;
@@ -801,7 +792,7 @@ static bool GetOptimizedCodeLater(CompilationInfo* info) {
 
   if (FLAG_trace_concurrent_recompilation) {
     PrintF("  ** Queued ");
-    info->closure()->PrintName();
+    info->closure()->ShortPrint();
     if (info->is_osr()) {
       PrintF(" for concurrent OSR at %d.\n", info->osr_ast_id().ToInt());
     } else {
@@ -1347,13 +1338,6 @@ MaybeHandle<Code> Compiler::GetOptimizedCode(Handle<JSFunction> function,
     if (GetOptimizedCodeNow(info.get())) return info->code();
   }
 
-  // Failed.
-  if (FLAG_trace_opt) {
-    PrintF("[failed to optimize ");
-    function->PrintName();
-    PrintF(": %s]\n", GetBailoutReason(info->bailout_reason()));
-  }
-
   if (isolate->has_pending_exception()) isolate->clear_pending_exception();
   return MaybeHandle<Code>();
 }
@@ -1371,36 +1355,41 @@ Handle<Code> Compiler::GetConcurrentlyOptimizedCode(OptimizedCompileJob* job) {
   Handle<SharedFunctionInfo> shared = info->shared_info();
   shared->code()->set_profiler_ticks(0);
 
-  // 1) Optimization may have failed.
+  // 1) Optimization on the concurrent thread may have failed.
   // 2) The function may have already been optimized by OSR.  Simply continue.
   //    Except when OSR already disabled optimization for some reason.
   // 3) The code may have already been invalidated due to dependency change.
   // 4) Debugger may have been activated.
-
-  if (job->last_status() != OptimizedCompileJob::SUCCEEDED ||
-      shared->optimization_disabled() ||
-      info->HasAbortedDueToDependencyChange() ||
-      isolate->DebuggerHasBreakPoints()) {
-    return Handle<Code>::null();
-  }
-
-  if (job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) {
-    return Handle<Code>::null();
-  }
-
-  RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info.get(), shared);
-  if (info->shared_info()->SearchOptimizedCodeMap(
-          info->context()->native_context(), info->osr_ast_id()) == -1) {
-    InsertCodeIntoOptimizedCodeMap(info.get());
+  // 5) Code generation may have failed.
+  if (job->last_status() == OptimizedCompileJob::SUCCEEDED) {
+    if (shared->optimization_disabled()) {
+      job->RetryOptimization(kOptimizationDisabled);
+    } else if (info->HasAbortedDueToDependencyChange()) {
+      job->RetryOptimization(kBailedOutDueToDependencyChange);
+    } else if (isolate->DebuggerHasBreakPoints()) {
+      job->RetryOptimization(kDebuggerHasBreakPoints);
+    } else if (job->GenerateCode() == OptimizedCompileJob::SUCCEEDED) {
+      RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info.get(), shared);
+      if (info->shared_info()->SearchOptimizedCodeMap(
+              info->context()->native_context(), info->osr_ast_id()) == -1) {
+        InsertCodeIntoOptimizedCodeMap(info.get());
+      }
+      if (FLAG_trace_opt) {
+        PrintF("[completed optimizing ");
+        info->closure()->ShortPrint();
+        PrintF("]\n");
+      }
+      return Handle<Code>(*info->code());
+    }
   }
 
-  if (FLAG_trace_concurrent_recompilation) {
-    PrintF("  ** Optimized code for ");
-    info->closure()->PrintName();
-    PrintF(" generated.\n");
+  DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED);
+  if (FLAG_trace_opt) {
+    PrintF("[aborted optimizing ");
+    info->closure()->ShortPrint();
+    PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
   }
-
-  return Handle<Code>(*info->code());
+  return Handle<Code>::null();
 }
 
 
index ea93f408c653127fe2c3cd58bf49140df3efdf6b..9617afc9f3c8729a5e375f8a99f2b9bc677012d3 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "src/allocation.h"
 #include "src/ast.h"
+#include "src/bailout-reason.h"
 #include "src/zone.h"
 
 namespace v8 {
@@ -82,7 +83,9 @@ class CompilationInfo {
     kSerializing = 1 << 15,
     kContextSpecializing = 1 << 16,
     kInliningEnabled = 1 << 17,
-    kTypingEnabled = 1 << 18
+    kTypingEnabled = 1 << 18,
+    kDisableFutureOptimization = 1 << 19,
+    kAbortedDueToDependency = 1 << 20
   };
 
   CompilationInfo(Handle<JSFunction> closure, Zone* zone);
@@ -319,8 +322,16 @@ class CompilationInfo {
     SaveHandle(&unoptimized_code_);
   }
 
+  void AbortOptimization(BailoutReason reason) {
+    if (bailout_reason_ != kNoReason) bailout_reason_ = reason;
+    SetFlag(kDisableFutureOptimization);
+  }
+
+  void RetryOptimization(BailoutReason reason) {
+    if (bailout_reason_ != kNoReason) bailout_reason_ = reason;
+  }
+
   BailoutReason bailout_reason() const { return bailout_reason_; }
-  void set_bailout_reason(BailoutReason reason) { bailout_reason_ = reason; }
 
   int prologue_offset() const {
     DCHECK_NE(Code::kPrologueOffsetNotSet, prologue_offset_);
@@ -355,12 +366,12 @@ class CompilationInfo {
 
   void AbortDueToDependencyChange() {
     DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
-    abort_due_to_dependency_ = true;
+    SetFlag(kAbortedDueToDependency);
   }
 
-  bool HasAbortedDueToDependencyChange() {
+  bool HasAbortedDueToDependencyChange() const {
     DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
-    return abort_due_to_dependency_;
+    return GetFlag(kAbortedDueToDependency);
   }
 
   bool HasSameOsrEntry(Handle<JSFunction> function, BailoutId osr_ast_id) {
@@ -462,9 +473,6 @@ class CompilationInfo {
   // data.  Keep track which code we patched.
   Handle<Code> unoptimized_code_;
 
-  // Flag whether compilation needs to be aborted due to dependency change.
-  bool abort_due_to_dependency_;
-
   // The zone from which the compilation pipeline working on this
   // CompilationInfo allocates.
   Zone* zone_;
@@ -588,18 +596,13 @@ class OptimizedCompileJob: public ZoneObject {
   CompilationInfo* info() const { return info_; }
   Isolate* isolate() const { return info()->isolate(); }
 
-  MUST_USE_RESULT Status AbortOptimization(
-      BailoutReason reason = kNoReason) {
-    if (reason != kNoReason) info_->set_bailout_reason(reason);
+  Status RetryOptimization(BailoutReason reason) {
+    info_->RetryOptimization(reason);
     return SetLastStatus(BAILED_OUT);
   }
 
-  MUST_USE_RESULT Status AbortAndDisableOptimization(
-      BailoutReason reason = kNoReason) {
-    if (reason != kNoReason) info_->set_bailout_reason(reason);
-    // Reference to shared function info does not change between phases.
-    AllowDeferredHandleDereference allow_handle_dereference;
-    info_->shared_info()->DisableOptimization(info_->bailout_reason());
+  Status AbortOptimization(BailoutReason reason) {
+    info_->AbortOptimization(reason);
     return SetLastStatus(BAILED_OUT);
   }
 
index 31d53e44ee327680c41de747d84fadfc4f65e150..9889b6a030263faa6f63b393f5fed994319ad269 100644 (file)
@@ -386,12 +386,12 @@ Handle<Code> Pipeline::GenerateCode(Linkage* linkage, Graph* graph,
   {
     int node_count = graph->NodeCount();
     if (node_count > UnallocatedOperand::kMaxVirtualRegisters) {
-      linkage->info()->set_bailout_reason(kNotEnoughVirtualRegistersForValues);
+      linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersForValues);
       return Handle<Code>::null();
     }
     RegisterAllocator allocator(&sequence);
     if (!allocator.Allocate()) {
-      linkage->info()->set_bailout_reason(kNotEnoughVirtualRegistersRegalloc);
+      linkage->info()->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
       return Handle<Code>::null();
     }
   }
index dfadbe56f61f64e0a75c791cefcd130d84eb998b..e8360a09f98d516aa682806960a6e6b9705c88cf 100644 (file)
@@ -3326,7 +3326,6 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
       break_scope_(NULL),
       inlined_count_(0),
       globals_(10, info->zone()),
-      inline_bailout_(false),
       osr_(new(info->zone()) HOsrBuilder(this)) {
   // This is not initialized in the initializer list because the
   // constructor for the initial state relies on function_state_ == NULL
@@ -4211,7 +4210,7 @@ void TestContext::BuildBranch(HValue* value) {
 
 
 void HOptimizedGraphBuilder::Bailout(BailoutReason reason) {
-  current_info()->set_bailout_reason(reason);
+  current_info()->AbortOptimization(reason);
   SetStackOverflow();
 }
 
@@ -7931,10 +7930,10 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
   set_scope(saved_scope);
   if (HasStackOverflow()) {
     // Bail out if the inline function did, as we cannot residualize a call
-    // instead.
+    // instead, but do not disable optimization for the outer function.
     TraceInline(target, caller, "inline graph construction failed");
     target_shared->DisableOptimization(kInliningBailedOut);
-    inline_bailout_ = true;
+    current_info()->RetryOptimization(kInliningBailedOut);
     delete target_state;
     return true;
   }
index d5e208f3709977d7a6354fb05c2617fffce5dda4..d507643e5f295fb9323be0d958917c0809094026 100644 (file)
@@ -10,6 +10,7 @@
 #include "src/accessors.h"
 #include "src/allocation.h"
 #include "src/ast.h"
+#include "src/bailout-reason.h"
 #include "src/compiler.h"
 #include "src/hydrogen-instructions.h"
 #include "src/scopes.h"
@@ -2109,8 +2110,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
   BreakAndContinueScope* break_scope() const { return break_scope_; }
   void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; }
 
-  bool inline_bailout() { return inline_bailout_; }
-
   HValue* context() { return environment()->context(); }
 
   HOsrBuilder* osr() const { return osr_; }
index 9b8970e4f11b0b299349d185b37e465e08da7017..3ed6623e9d6617e88aa2cfff3df53388c380f28c 100644 (file)
@@ -461,12 +461,6 @@ LPlatformChunk* LChunkBuilder::Build() {
 }
 
 
-void LChunkBuilder::Abort(BailoutReason reason) {
-  info()->set_bailout_reason(reason);
-  status_ = ABORTED;
-}
-
-
 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
   return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
                                   Register::ToAllocationIndex(reg));
@@ -2532,7 +2526,7 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
   } else {
     spill_index = env_index - instr->environment()->first_local_index();
     if (spill_index > LUnallocated::kMaxFixedSlotIndex) {
-      Abort(kNotEnoughSpillSlotsForOsr);
+      Retry(kNotEnoughSpillSlotsForOsr);
       spill_index = 0;
     }
     if (spill_index == 0) {
index c7955fea427fd7337d227e8180b51c63c84149e1..75fed82538ce842040096fa65da6b2f4d780ed88 100644 (file)
@@ -2750,17 +2750,11 @@ class LPlatformChunk FINAL : public LChunk {
 class LChunkBuilder FINAL : public LChunkBuilderBase {
  public:
   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
-      : LChunkBuilderBase(graph->zone()),
-        chunk_(NULL),
-        info_(info),
-        graph_(graph),
-        status_(UNUSED),
+      : LChunkBuilderBase(info, graph),
         current_instruction_(NULL),
         current_block_(NULL),
         next_block_(NULL),
-        allocator_(allocator) { }
-
-  Isolate* isolate() const { return graph_->isolate(); }
+        allocator_(allocator) {}
 
   // Build the sequence for the graph.
   LPlatformChunk* Build();
@@ -2790,24 +2784,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
 
  private:
-  enum Status {
-    UNUSED,
-    BUILDING,
-    DONE,
-    ABORTED
-  };
-
-  LPlatformChunk* chunk() const { return chunk_; }
-  CompilationInfo* info() const { return info_; }
-  HGraph* graph() const { return graph_; }
-
-  bool is_unused() const { return status_ == UNUSED; }
-  bool is_building() const { return status_ == BUILDING; }
-  bool is_done() const { return status_ == DONE; }
-  bool is_aborted() const { return status_ == ABORTED; }
-
-  void Abort(BailoutReason reason);
-
   // Methods for getting operands for Use / Define / Temp.
   LUnallocated* ToUnallocated(Register reg);
   LUnallocated* ToUnallocated(XMMRegister reg);
@@ -2903,10 +2879,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
 
   LOperand* GetStoreKeyedValueOperand(HStoreKeyed* instr);
 
-  LPlatformChunk* chunk_;
-  CompilationInfo* info_;
-  HGraph* const graph_;
-  Status status_;
   HInstruction* current_instruction_;
   HBasicBlock* current_block_;
   HBasicBlock* next_block_;
index 52f375e90f0b6d5908ec5c65a85c5ab75f279840..81347e58f2e3d114879766ce96ca8de36cf69010 100644 (file)
@@ -6,6 +6,7 @@
 #define V8_IA32_MACRO_ASSEMBLER_IA32_H_
 
 #include "src/assembler.h"
+#include "src/bailout-reason.h"
 #include "src/frames.h"
 #include "src/globals.h"
 
index 0207188bd09b18f94471706bd3b41d1c1b58d350..ea6b83a06a68fb2de9d579a10c94dc836f9d08fa 100644 (file)
@@ -226,19 +226,25 @@ void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
 
 
 void LCodeGenBase::Abort(BailoutReason reason) {
-  info()->set_bailout_reason(reason);
+  info()->AbortOptimization(reason);
+  status_ = ABORTED;
+}
+
+
+void LCodeGenBase::Retry(BailoutReason reason) {
+  info()->RetryOptimization(reason);
   status_ = ABORTED;
 }
 
 
 void LCodeGenBase::AddDeprecationDependency(Handle<Map> map) {
-  if (map->is_deprecated()) return Abort(kMapBecameDeprecated);
+  if (map->is_deprecated()) return Retry(kMapBecameDeprecated);
   chunk_->AddDeprecationDependency(map);
 }
 
 
 void LCodeGenBase::AddStabilityDependency(Handle<Map> map) {
-  if (!map->is_stable()) return Abort(kMapBecameUnstable);
+  if (!map->is_stable()) return Retry(kMapBecameUnstable);
   chunk_->AddStabilityDependency(map);
 }
 
index 301debeb937c93e0cc85ee3a20d6d681fe3f0d84..40d4d8e4f8e733224f9c36e7c04c8a1e300c1dd7 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "src/v8.h"
 
+#include "src/bailout-reason.h"
 #include "src/compiler.h"
 #include "src/deoptimizer.h"
 
@@ -76,6 +77,7 @@ class LCodeGenBase BASE_EMBEDDED {
   bool is_aborted() const { return status_ == ABORTED; }
 
   void Abort(BailoutReason reason);
+  void Retry(BailoutReason reason);
 
   // Methods for code dependencies.
   void AddDeprecationDependency(Handle<Map> map);
index b29a4c590c13e49ab197a4f8c2e28c532fe33eff..7d992a1eb88fdf9a82b5ea0bcf2f13229c36d6db 100644 (file)
@@ -2,9 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "src/lithium.h"
+
 #include "src/v8.h"
 
-#include "src/lithium.h"
 #include "src/scopes.h"
 #include "src/serialize.h"
 
@@ -437,7 +438,7 @@ LChunk* LChunk::NewChunk(HGraph* graph) {
   int values = graph->GetMaximumValueID();
   CompilationInfo* info = graph->info();
   if (values > LUnallocated::kMaxVirtualRegisters) {
-    info->set_bailout_reason(kNotEnoughVirtualRegistersForValues);
+    info->AbortOptimization(kNotEnoughVirtualRegistersForValues);
     return NULL;
   }
   LAllocator allocator(values, graph);
@@ -446,7 +447,7 @@ LChunk* LChunk::NewChunk(HGraph* graph) {
   if (chunk == NULL) return NULL;
 
   if (!allocator.Allocate(chunk)) {
-    info->set_bailout_reason(kNotEnoughVirtualRegistersRegalloc);
+    info->AbortOptimization(kNotEnoughVirtualRegistersRegalloc);
     return NULL;
   }
 
@@ -510,6 +511,18 @@ void LChunk::set_allocated_double_registers(BitVector* allocated_registers) {
 }
 
 
+void LChunkBuilderBase::Abort(BailoutReason reason) {
+  info()->AbortOptimization(reason);
+  status_ = ABORTED;
+}
+
+
+void LChunkBuilderBase::Retry(BailoutReason reason) {
+  info()->RetryOptimization(reason);
+  status_ = ABORTED;
+}
+
+
 LEnvironment* LChunkBuilderBase::CreateEnvironment(
     HEnvironment* hydrogen_env, int* argument_index_accumulator,
     ZoneList<HValue*>* objects_to_materialize) {
index 9c3aab0b9e99c8bc2dbfe7bb3a685c38fd655f93..83f760d672b8c1cfb9ec5744b5c2ae096bc9a905 100644 (file)
@@ -8,6 +8,7 @@
 #include <set>
 
 #include "src/allocation.h"
+#include "src/bailout-reason.h"
 #include "src/hydrogen.h"
 #include "src/safepoint-table.h"
 #include "src/zone-allocator.h"
@@ -697,13 +698,34 @@ class LChunk : public ZoneObject {
 
 class LChunkBuilderBase BASE_EMBEDDED {
  public:
-  explicit LChunkBuilderBase(Zone* zone)
+  explicit LChunkBuilderBase(CompilationInfo* info, HGraph* graph)
       : argument_count_(0),
-        zone_(zone) { }
+        chunk_(NULL),
+        info_(info),
+        graph_(graph),
+        status_(UNUSED),
+        zone_(graph->zone()) {}
 
   virtual ~LChunkBuilderBase() { }
 
+  void Abort(BailoutReason reason);
+  void Retry(BailoutReason reason);
+
  protected:
+  enum Status { UNUSED, BUILDING, DONE, ABORTED };
+
+  LPlatformChunk* chunk() const { return chunk_; }
+  CompilationInfo* info() const { return info_; }
+  HGraph* graph() const { return graph_; }
+  int argument_count() const { return argument_count_; }
+  Isolate* isolate() const { return graph_->isolate(); }
+  Heap* heap() const { return isolate()->heap(); }
+
+  bool is_unused() const { return status_ == UNUSED; }
+  bool is_building() const { return status_ == BUILDING; }
+  bool is_done() const { return status_ == DONE; }
+  bool is_aborted() const { return status_ == ABORTED; }
+
   // An input operand in register, stack slot or a constant operand.
   // Will not be moved to a register even if one is freely available.
   virtual MUST_USE_RESULT LOperand* UseAny(HValue* value) = 0;
@@ -718,6 +740,10 @@ class LChunkBuilderBase BASE_EMBEDDED {
   Zone* zone() const { return zone_; }
 
   int argument_count_;
+  LPlatformChunk* chunk_;
+  CompilationInfo* info_;
+  HGraph* const graph_;
+  Status status_;
 
  private:
   Zone* zone_;
index 11c7a88de06d2622803eab6b0dc65646c7ca0b3c..86f5ce0967a849fb5a73cda5eec2cfa82e4f4764 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "src/v8.h"
 
+#include "src/bailout-reason.h"
 #include "src/base/platform/platform.h"
 #include "src/bootstrapper.h"
 #include "src/code-stubs.h"
index cc685577ce37cb029d57c98fb058bcd919fcc3bc..eed4554091a8be0cbc6fbd15548b6beda0b7f40a 100644 (file)
@@ -9113,7 +9113,7 @@ void JSFunction::MarkForConcurrentOptimization() {
   DCHECK(GetIsolate()->concurrent_recompilation_enabled());
   if (FLAG_trace_concurrent_recompilation) {
     PrintF("  ** Marking ");
-    PrintName();
+    ShortPrint();
     PrintF(" for concurrent recompilation.\n");
   }
   set_code_no_write_barrier(
@@ -9131,7 +9131,7 @@ void JSFunction::MarkInOptimizationQueue() {
   DCHECK(GetIsolate()->concurrent_recompilation_enabled());
   if (FLAG_trace_concurrent_recompilation) {
     PrintF("  ** Queueing ");
-    PrintName();
+    ShortPrint();
     PrintF(" for concurrent recompilation.\n");
   }
   set_code_no_write_barrier(
@@ -16360,16 +16360,4 @@ void PropertyCell::AddDependentCompilationInfo(Handle<PropertyCell> cell,
       cell, info->zone());
 }
 
-
-const char* GetBailoutReason(BailoutReason reason) {
-  DCHECK(reason < kLastErrorMessage);
-#define ERROR_MESSAGES_TEXTS(C, T) T,
-  static const char* error_messages_[] = {
-      ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
-  };
-#undef ERROR_MESSAGES_TEXTS
-  return error_messages_[reason];
-}
-
-
 } }  // namespace v8::internal
index 37227f9a07b37b35be6bcbe2e99712eef0d2d544..e2321974d3fb03c7b92fc726f3f1fa2411dc1d61 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "src/allocation.h"
 #include "src/assert-scope.h"
+#include "src/bailout-reason.h"
 #include "src/base/bits.h"
 #include "src/builtins.h"
 #include "src/checks.h"
@@ -983,335 +984,6 @@ template <class C> inline bool Is(Object* obj);
   V(WeakHashTable)                 \
   V(OrderedHashTable)
 
-
-#define ERROR_MESSAGES_LIST(V)                                                 \
-  V(kNoReason, "no reason")                                                    \
-                                                                               \
-  V(k32BitValueInRegisterIsNotZeroExtended,                                    \
-    "32 bit value in register is not zero-extended")                           \
-  V(kAlignmentMarkerExpected, "Alignment marker expected")                     \
-  V(kAllocationIsNotDoubleAligned, "Allocation is not double aligned")         \
-  V(kAPICallReturnedInvalidObject, "API call returned invalid object")         \
-  V(kArgumentsObjectValueInATestContext,                                       \
-    "Arguments object value in a test context")                                \
-  V(kArrayBoilerplateCreationFailed, "Array boilerplate creation failed")      \
-  V(kArrayIndexConstantValueTooBig, "Array index constant value too big")      \
-  V(kAssignmentToArguments, "Assignment to arguments")                         \
-  V(kAssignmentToLetVariableBeforeInitialization,                              \
-    "Assignment to let variable before initialization")                        \
-  V(kAssignmentToLOOKUPVariable, "Assignment to LOOKUP variable")              \
-  V(kAssignmentToParameterFunctionUsesArgumentsObject,                         \
-    "Assignment to parameter, function uses arguments object")                 \
-  V(kAssignmentToParameterInArgumentsObject,                                   \
-    "Assignment to parameter in arguments object")                             \
-  V(kAttemptToUseUndefinedCache, "Attempt to use undefined cache")             \
-  V(kBadValueContextForArgumentsObjectValue,                                   \
-    "Bad value context for arguments object value")                            \
-  V(kBadValueContextForArgumentsValue,                                         \
-    "Bad value context for arguments value")                                   \
-  V(kBailedOutDueToDependencyChange, "Bailed out due to dependency change")    \
-  V(kBailoutWasNotPrepared, "Bailout was not prepared")                        \
-  V(kBinaryStubGenerateFloatingPointCode,                                      \
-    "BinaryStub_GenerateFloatingPointCode")                                    \
-  V(kBothRegistersWereSmisInSelectNonSmi,                                      \
-    "Both registers were smis in SelectNonSmi")                                \
-  V(kCallToAJavaScriptRuntimeFunction,                                         \
-    "Call to a JavaScript runtime function")                                   \
-  V(kCannotTranslatePositionInChangedArea,                                     \
-    "Cannot translate position in changed area")                               \
-  V(kClassLiteral, "Class literal")                                            \
-  V(kCodeGenerationFailed, "Code generation failed")                           \
-  V(kCodeObjectNotProperlyPatched, "Code object not properly patched")         \
-  V(kCompoundAssignmentToLookupSlot, "Compound assignment to lookup slot")     \
-  V(kContextAllocatedArguments, "Context-allocated arguments")                 \
-  V(kCopyBuffersOverlap, "Copy buffers overlap")                               \
-  V(kCouldNotGenerateZero, "Could not generate +0.0")                          \
-  V(kCouldNotGenerateNegativeZero, "Could not generate -0.0")                  \
-  V(kDebuggerHasBreakPoints, "Debugger has break points")                      \
-  V(kDebuggerStatement, "DebuggerStatement")                                   \
-  V(kDeclarationInCatchContext, "Declaration in catch context")                \
-  V(kDeclarationInWithContext, "Declaration in with context")                  \
-  V(kDefaultNaNModeNotSet, "Default NaN mode not set")                         \
-  V(kDeleteWithGlobalVariable, "Delete with global variable")                  \
-  V(kDeleteWithNonGlobalVariable, "Delete with non-global variable")           \
-  V(kDestinationOfCopyNotAligned, "Destination of copy not aligned")           \
-  V(kDontDeleteCellsCannotContainTheHole,                                      \
-    "DontDelete cells can't contain the hole")                                 \
-  V(kDoPushArgumentNotImplementedForDoubleType,                                \
-    "DoPushArgument not implemented for double type")                          \
-  V(kEliminatedBoundsCheckFailed, "Eliminated bounds check failed")            \
-  V(kEmitLoadRegisterUnsupportedDoubleImmediate,                               \
-    "EmitLoadRegister: Unsupported double immediate")                          \
-  V(kEval, "eval")                                                             \
-  V(kExpected0AsASmiSentinel, "Expected 0 as a Smi sentinel")                  \
-  V(kExpectedAlignmentMarker, "Expected alignment marker")                     \
-  V(kExpectedAllocationSite, "Expected allocation site")                       \
-  V(kExpectedFunctionObject, "Expected function object in register")           \
-  V(kExpectedHeapNumber, "Expected HeapNumber")                                \
-  V(kExpectedNativeContext, "Expected native context")                         \
-  V(kExpectedNonIdenticalObjects, "Expected non-identical objects")            \
-  V(kExpectedNonNullContext, "Expected non-null context")                      \
-  V(kExpectedPositiveZero, "Expected +0.0")                                    \
-  V(kExpectedAllocationSiteInCell, "Expected AllocationSite in property cell") \
-  V(kExpectedFixedArrayInFeedbackVector,                                       \
-    "Expected fixed array in feedback vector")                                 \
-  V(kExpectedFixedArrayInRegisterA2, "Expected fixed array in register a2")    \
-  V(kExpectedFixedArrayInRegisterEbx, "Expected fixed array in register ebx")  \
-  V(kExpectedFixedArrayInRegisterR2, "Expected fixed array in register r2")    \
-  V(kExpectedFixedArrayInRegisterRbx, "Expected fixed array in register rbx")  \
-  V(kExpectedNewSpaceObject, "Expected new space object")                      \
-  V(kExpectedSmiOrHeapNumber, "Expected smi or HeapNumber")                    \
-  V(kExpectedUndefinedOrCell, "Expected undefined or cell in register")        \
-  V(kExpectingAlignmentForCopyBytes, "Expecting alignment for CopyBytes")      \
-  V(kExportDeclaration, "Export declaration")                                  \
-  V(kExternalStringExpectedButNotFound,                                        \
-    "External string expected, but not found")                                 \
-  V(kFailedBailedOutLastTime, "Failed/bailed out last time")                   \
-  V(kForInStatementIsNotFastCase, "ForInStatement is not fast case")           \
-  V(kForInStatementOptimizationIsDisabled,                                     \
-    "ForInStatement optimization is disabled")                                 \
-  V(kForInStatementWithNonLocalEachVariable,                                   \
-    "ForInStatement with non-local each variable")                             \
-  V(kForOfStatement, "ForOfStatement")                                         \
-  V(kFrameIsExpectedToBeAligned, "Frame is expected to be aligned")            \
-  V(kFunctionCallsEval, "Function calls eval")                                 \
-  V(kFunctionIsAGenerator, "Function is a generator")                          \
-  V(kFunctionWithIllegalRedeclaration, "Function with illegal redeclaration")  \
-  V(kGeneratedCodeIsTooLarge, "Generated code is too large")                   \
-  V(kGeneratorFailedToResume, "Generator failed to resume")                    \
-  V(kGenerator, "Generator")                                                   \
-  V(kGlobalFunctionsMustHaveInitialMap,                                        \
-    "Global functions must have initial map")                                  \
-  V(kHeapNumberMapRegisterClobbered, "HeapNumberMap register clobbered")       \
-  V(kHydrogenFilter, "Optimization disabled by filter")                        \
-  V(kImportDeclaration, "Import declaration")                                  \
-  V(kImproperObjectOnPrototypeChainForStore,                                   \
-    "Improper object on prototype chain for store")                            \
-  V(kIndexIsNegative, "Index is negative")                                     \
-  V(kIndexIsTooLarge, "Index is too large")                                    \
-  V(kInlinedRuntimeFunctionClassOf, "Inlined runtime function: ClassOf")       \
-  V(kInlinedRuntimeFunctionFastOneByteArrayJoin,                               \
-    "Inlined runtime function: FastOneByteArrayJoin")                          \
-  V(kInlinedRuntimeFunctionGeneratorNext,                                      \
-    "Inlined runtime function: GeneratorNext")                                 \
-  V(kInlinedRuntimeFunctionGeneratorThrow,                                     \
-    "Inlined runtime function: GeneratorThrow")                                \
-  V(kInlinedRuntimeFunctionGetFromCache,                                       \
-    "Inlined runtime function: GetFromCache")                                  \
-  V(kInlinedRuntimeFunctionIsNonNegativeSmi,                                   \
-    "Inlined runtime function: IsNonNegativeSmi")                              \
-  V(kInlinedRuntimeFunctionIsStringWrapperSafeForDefaultValueOf,               \
-    "Inlined runtime function: IsStringWrapperSafeForDefaultValueOf")          \
-  V(kInliningBailedOut, "Inlining bailed out")                                 \
-  V(kInputGPRIsExpectedToHaveUpper32Cleared,                                   \
-    "Input GPR is expected to have upper32 cleared")                           \
-  V(kInputStringTooLong, "Input string too long")                              \
-  V(kInstanceofStubUnexpectedCallSiteCacheCheck,                               \
-    "InstanceofStub unexpected call site cache (check)")                       \
-  V(kInstanceofStubUnexpectedCallSiteCacheCmp1,                                \
-    "InstanceofStub unexpected call site cache (cmp 1)")                       \
-  V(kInstanceofStubUnexpectedCallSiteCacheCmp2,                                \
-    "InstanceofStub unexpected call site cache (cmp 2)")                       \
-  V(kInstanceofStubUnexpectedCallSiteCacheMov,                                 \
-    "InstanceofStub unexpected call site cache (mov)")                         \
-  V(kInteger32ToSmiFieldWritingToNonSmiLocation,                               \
-    "Integer32ToSmiField writing to non-smi location")                         \
-  V(kInvalidCaptureReferenced, "Invalid capture referenced")                   \
-  V(kInvalidElementsKindForInternalArrayOrInternalPackedArray,                 \
-    "Invalid ElementsKind for InternalArray or InternalPackedArray")           \
-  V(kInvalidFullCodegenState, "invalid full-codegen state")                    \
-  V(kInvalidHandleScopeLevel, "Invalid HandleScope level")                     \
-  V(kInvalidLeftHandSideInAssignment, "Invalid left-hand side in assignment")  \
-  V(kInvalidLhsInCompoundAssignment, "Invalid lhs in compound assignment")     \
-  V(kInvalidLhsInCountOperation, "Invalid lhs in count operation")             \
-  V(kInvalidMinLength, "Invalid min_length")                                   \
-  V(kJSGlobalObjectNativeContextShouldBeANativeContext,                        \
-    "JSGlobalObject::native_context should be a native context")               \
-  V(kJSGlobalProxyContextShouldNotBeNull,                                      \
-    "JSGlobalProxy::context() should not be null")                             \
-  V(kJSObjectWithFastElementsMapHasSlowElements,                               \
-    "JSObject with fast elements map has slow elements")                       \
-  V(kLetBindingReInitialization, "Let binding re-initialization")              \
-  V(kLhsHasBeenClobbered, "lhs has been clobbered")                            \
-  V(kLiveBytesCountOverflowChunkSize, "Live Bytes Count overflow chunk size")  \
-  V(kLiveEdit, "LiveEdit")                                                     \
-  V(kLookupVariableInCountOperation, "Lookup variable in count operation")     \
-  V(kMapBecameDeprecated, "Map became deprecated")                             \
-  V(kMapBecameUnstable, "Map became unstable")                                 \
-  V(kMapIsNoLongerInEax, "Map is no longer in eax")                            \
-  V(kModuleDeclaration, "Module declaration")                                  \
-  V(kModuleLiteral, "Module literal")                                          \
-  V(kModulePath, "Module path")                                                \
-  V(kModuleStatement, "Module statement")                                      \
-  V(kModuleVariable, "Module variable")                                        \
-  V(kModuleUrl, "Module url")                                                  \
-  V(kNativeFunctionLiteral, "Native function literal")                         \
-  V(kSuperReference, "Super reference")                                        \
-  V(kNeedSmiLiteral, "Need a Smi literal here")                                \
-  V(kNoCasesLeft, "No cases left")                                             \
-  V(kNoEmptyArraysHereInEmitFastOneByteArrayJoin,                              \
-    "No empty arrays here in EmitFastOneByteArrayJoin")                        \
-  V(kNonInitializerAssignmentToConst, "Non-initializer assignment to const")   \
-  V(kNonSmiIndex, "Non-smi index")                                             \
-  V(kNonSmiKeyInArrayLiteral, "Non-smi key in array literal")                  \
-  V(kNonSmiValue, "Non-smi value")                                             \
-  V(kNonObject, "Non-object value")                                            \
-  V(kNotEnoughVirtualRegistersForValues,                                       \
-    "Not enough virtual registers for values")                                 \
-  V(kNotEnoughSpillSlotsForOsr, "Not enough spill slots for OSR")              \
-  V(kNotEnoughVirtualRegistersRegalloc,                                        \
-    "Not enough virtual registers (regalloc)")                                 \
-  V(kObjectFoundInSmiOnlyArray, "Object found in smi-only array")              \
-  V(kObjectLiteralWithComplexProperty, "Object literal with complex property") \
-  V(kOddballInStringTableIsNotUndefinedOrTheHole,                              \
-    "Oddball in string table is not undefined or the hole")                    \
-  V(kOffsetOutOfRange, "Offset out of range")                                  \
-  V(kOperandIsASmiAndNotAName, "Operand is a smi and not a name")              \
-  V(kOperandIsASmiAndNotAString, "Operand is a smi and not a string")          \
-  V(kOperandIsASmi, "Operand is a smi")                                        \
-  V(kOperandIsNotAName, "Operand is not a name")                               \
-  V(kOperandIsNotANumber, "Operand is not a number")                           \
-  V(kOperandIsNotASmi, "Operand is not a smi")                                 \
-  V(kOperandIsNotAString, "Operand is not a string")                           \
-  V(kOperandIsNotSmi, "Operand is not smi")                                    \
-  V(kOperandNotANumber, "Operand not a number")                                \
-  V(kObjectTagged, "The object is tagged")                                     \
-  V(kObjectNotTagged, "The object is not tagged")                              \
-  V(kOptimizationDisabled, "Optimization is disabled")                         \
-  V(kOptimizedTooManyTimes, "Optimized too many times")                        \
-  V(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister,                   \
-    "Out of virtual registers while trying to allocate temp register")         \
-  V(kParseScopeError, "Parse/scope error")                                     \
-  V(kPossibleDirectCallToEval, "Possible direct call to eval")                 \
-  V(kPreconditionsWereNotMet, "Preconditions were not met")                    \
-  V(kPropertyAllocationCountFailed, "Property allocation count failed")        \
-  V(kReceivedInvalidReturnAddress, "Received invalid return address")          \
-  V(kReferenceToAVariableWhichRequiresDynamicLookup,                           \
-    "Reference to a variable which requires dynamic lookup")                   \
-  V(kReferenceToGlobalLexicalVariable, "Reference to global lexical variable") \
-  V(kReferenceToUninitializedVariable, "Reference to uninitialized variable")  \
-  V(kRegisterDidNotMatchExpectedRoot, "Register did not match expected root")  \
-  V(kRegisterWasClobbered, "Register was clobbered")                           \
-  V(kRememberedSetPointerInNewSpace, "Remembered set pointer is in new space") \
-  V(kReturnAddressNotFoundInFrame, "Return address not found in frame")        \
-  V(kRhsHasBeenClobbered, "Rhs has been clobbered")                            \
-  V(kScopedBlock, "ScopedBlock")                                               \
-  V(kSmiAdditionOverflow, "Smi addition overflow")                             \
-  V(kSmiSubtractionOverflow, "Smi subtraction overflow")                       \
-  V(kStackAccessBelowStackPointer, "Stack access below stack pointer")         \
-  V(kStackFrameTypesMustMatch, "Stack frame types must match")                 \
-  V(kTheCurrentStackPointerIsBelowCsp,                                         \
-    "The current stack pointer is below csp")                                  \
-  V(kTheInstructionShouldBeALui, "The instruction should be a lui")            \
-  V(kTheInstructionShouldBeAnOri, "The instruction should be an ori")          \
-  V(kTheInstructionToPatchShouldBeALoadFromConstantPool,                       \
-    "The instruction to patch should be a load from the constant pool")        \
-  V(kTheInstructionToPatchShouldBeAnLdrLiteral,                                \
-    "The instruction to patch should be a ldr literal")                        \
-  V(kTheInstructionToPatchShouldBeALui,                                        \
-    "The instruction to patch should be a lui")                                \
-  V(kTheInstructionToPatchShouldBeAnOri,                                       \
-    "The instruction to patch should be an ori")                               \
-  V(kTheSourceAndDestinationAreTheSame,                                        \
-    "The source and destination are the same")                                 \
-  V(kTheStackPointerIsNotAligned, "The stack pointer is not aligned.")         \
-  V(kTheStackWasCorruptedByMacroAssemblerCall,                                 \
-    "The stack was corrupted by MacroAssembler::Call()")                       \
-  V(kTooManyParametersLocals, "Too many parameters/locals")                    \
-  V(kTooManyParameters, "Too many parameters")                                 \
-  V(kTooManySpillSlotsNeededForOSR, "Too many spill slots needed for OSR")     \
-  V(kToOperand32UnsupportedImmediate, "ToOperand32 unsupported immediate.")    \
-  V(kToOperandIsDoubleRegisterUnimplemented,                                   \
-    "ToOperand IsDoubleRegister unimplemented")                                \
-  V(kToOperandUnsupportedDoubleImmediate,                                      \
-    "ToOperand Unsupported double immediate")                                  \
-  V(kTryCatchStatement, "TryCatchStatement")                                   \
-  V(kTryFinallyStatement, "TryFinallyStatement")                               \
-  V(kUnableToEncodeValueAsSmi, "Unable to encode value as smi")                \
-  V(kUnalignedAllocationInNewSpace, "Unaligned allocation in new space")       \
-  V(kUnalignedCellInWriteBarrier, "Unaligned cell in write barrier")           \
-  V(kUndefinedValueNotLoaded, "Undefined value not loaded")                    \
-  V(kUndoAllocationOfNonAllocatedMemory,                                       \
-    "Undo allocation of non allocated memory")                                 \
-  V(kUnexpectedAllocationTop, "Unexpected allocation top")                     \
-  V(kUnexpectedColorFound, "Unexpected color bit pattern found")               \
-  V(kUnexpectedElementsKindInArrayConstructor,                                 \
-    "Unexpected ElementsKind in array constructor")                            \
-  V(kUnexpectedFallthroughFromCharCodeAtSlowCase,                              \
-    "Unexpected fallthrough from CharCodeAt slow case")                        \
-  V(kUnexpectedFallthroughFromCharFromCodeSlowCase,                            \
-    "Unexpected fallthrough from CharFromCode slow case")                      \
-  V(kUnexpectedFallThroughFromStringComparison,                                \
-    "Unexpected fall-through from string comparison")                          \
-  V(kUnexpectedFallThroughInBinaryStubGenerateFloatingPointCode,               \
-    "Unexpected fall-through in BinaryStub_GenerateFloatingPointCode")         \
-  V(kUnexpectedFallthroughToCharCodeAtSlowCase,                                \
-    "Unexpected fallthrough to CharCodeAt slow case")                          \
-  V(kUnexpectedFallthroughToCharFromCodeSlowCase,                              \
-    "Unexpected fallthrough to CharFromCode slow case")                        \
-  V(kUnexpectedFPUStackDepthAfterInstruction,                                  \
-    "Unexpected FPU stack depth after instruction")                            \
-  V(kUnexpectedInitialMapForArrayFunction1,                                    \
-    "Unexpected initial map for Array function (1)")                           \
-  V(kUnexpectedInitialMapForArrayFunction2,                                    \
-    "Unexpected initial map for Array function (2)")                           \
-  V(kUnexpectedInitialMapForArrayFunction,                                     \
-    "Unexpected initial map for Array function")                               \
-  V(kUnexpectedInitialMapForInternalArrayFunction,                             \
-    "Unexpected initial map for InternalArray function")                       \
-  V(kUnexpectedLevelAfterReturnFromApiCall,                                    \
-    "Unexpected level after return from api call")                             \
-  V(kUnexpectedNegativeValue, "Unexpected negative value")                     \
-  V(kUnexpectedNumberOfPreAllocatedPropertyFields,                             \
-    "Unexpected number of pre-allocated property fields")                      \
-  V(kUnexpectedFPCRMode, "Unexpected FPCR mode.")                              \
-  V(kUnexpectedSmi, "Unexpected smi value")                                    \
-  V(kUnexpectedStringFunction, "Unexpected String function")                   \
-  V(kUnexpectedStringType, "Unexpected string type")                           \
-  V(kUnexpectedStringWrapperInstanceSize,                                      \
-    "Unexpected string wrapper instance size")                                 \
-  V(kUnexpectedTypeForRegExpDataFixedArrayExpected,                            \
-    "Unexpected type for RegExp data, FixedArray expected")                    \
-  V(kUnexpectedValue, "Unexpected value")                                      \
-  V(kUnexpectedUnusedPropertiesOfStringWrapper,                                \
-    "Unexpected unused properties of string wrapper")                          \
-  V(kUnimplemented, "unimplemented")                                           \
-  V(kUninitializedKSmiConstantRegister, "Uninitialized kSmiConstantRegister")  \
-  V(kUnknown, "Unknown")                                                       \
-  V(kUnsupportedConstCompoundAssignment,                                       \
-    "Unsupported const compound assignment")                                   \
-  V(kUnsupportedCountOperationWithConst,                                       \
-    "Unsupported count operation with const")                                  \
-  V(kUnsupportedDoubleImmediate, "Unsupported double immediate")               \
-  V(kUnsupportedLetCompoundAssignment, "Unsupported let compound assignment")  \
-  V(kUnsupportedLookupSlotInDeclaration,                                       \
-    "Unsupported lookup slot in declaration")                                  \
-  V(kUnsupportedNonPrimitiveCompare, "Unsupported non-primitive compare")      \
-  V(kUnsupportedPhiUseOfArguments, "Unsupported phi use of arguments")         \
-  V(kUnsupportedPhiUseOfConstVariable,                                         \
-    "Unsupported phi use of const variable")                                   \
-  V(kUnsupportedTaggedImmediate, "Unsupported tagged immediate")               \
-  V(kVariableResolvedToWithContext, "Variable resolved to with context")       \
-  V(kWeShouldNotHaveAnEmptyLexicalContext,                                     \
-    "We should not have an empty lexical context")                             \
-  V(kWithStatement, "WithStatement")                                           \
-  V(kWrongFunctionContext, "Wrong context passed to function")                 \
-  V(kWrongAddressOrValuePassedToRecordWrite,                                   \
-    "Wrong address or value passed to RecordWrite")                            \
-  V(kYield, "Yield")
-
-
-#define ERROR_MESSAGES_CONSTANTS(C, T) C,
-enum BailoutReason {
-  ERROR_MESSAGES_LIST(ERROR_MESSAGES_CONSTANTS)
-  kLastErrorMessage
-};
-#undef ERROR_MESSAGES_CONSTANTS
-
-
-const char* GetBailoutReason(BailoutReason reason);
-
-
 // Object is the abstract superclass for all classes in the
 // object hierarchy.
 // Object does not use any virtual functions to avoid the
index 0074adbefe1e10a650e76f33ba8711e75bcf5ee6..387e9c055cf99e3ee01f0f4bf0bcbffd822bdaa9 100644 (file)
@@ -226,7 +226,7 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() {
     if (info->is_osr()) {
       if (FLAG_trace_osr) {
         PrintF("[COSR - ");
-        info->closure()->PrintName();
+        function->ShortPrint();
         PrintF(" is ready for install and entry at AST id %d]\n",
                info->osr_ast_id().ToInt());
       }
@@ -237,6 +237,11 @@ void OptimizingCompilerThread::InstallOptimizedFunctions() {
       BackEdgeTable::RemoveStackCheck(code, offset);
     } else {
       if (function->IsOptimized()) {
+        if (FLAG_trace_concurrent_recompilation) {
+          PrintF("  ** Aborting compilation for ");
+          function->ShortPrint();
+          PrintF(" as it has already been optimized.\n");
+        }
         DisposeOptimizedCompileJob(job, false);
       } else {
         Handle<Code> code = Compiler::GetConcurrentlyOptimizedCode(job);
index 0d3dc92cc16552f8084b94808c7a1f5e612b4364..7cef210aeb52f40152d01694ef8b26fde34cc1bc 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "src/api.h"
 #include "src/ast.h"
+#include "src/bailout-reason.h"
 #include "src/base/platform/platform.h"
 #include "src/bootstrapper.h"
 #include "src/char-predicates-inl.h"
index bdcc42ba16c87336dfc300b176d5ca2bd4ac0ed1..78f6a269f024a1a10d6a940102f937f748f8e8d1 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "src/v8.h"
 
+#include "src/bailout-reason.h"
 #include "src/func-name-inferrer.h"
 #include "src/hashmap.h"
 #include "src/scanner.h"
index 3ecf04430a82632a615aab7f097f97a0959cda8d..5209de4684be1bb697cdd989b2acf68035dfcf31 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/allocation-site-scopes.h"
 #include "src/api.h"
 #include "src/arguments.h"
+#include "src/bailout-reason.h"
 #include "src/base/cpu.h"
 #include "src/base/platform/platform.h"
 #include "src/bootstrapper.h"
index 815038b9e699d2fa053f8c9b912da22e9045166b..69f50b1beed5fbed238f7c711bc22f15aff12cff 100644 (file)
@@ -449,12 +449,6 @@ LPlatformChunk* LChunkBuilder::Build() {
 }
 
 
-void LChunkBuilder::Abort(BailoutReason reason) {
-  info()->set_bailout_reason(reason);
-  status_ = ABORTED;
-}
-
-
 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
   return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
                                   Register::ToAllocationIndex(reg));
@@ -2513,7 +2507,7 @@ LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
   } else {
     spill_index = env_index - instr->environment()->first_local_index();
     if (spill_index > LUnallocated::kMaxFixedSlotIndex) {
-      Abort(kTooManySpillSlotsNeededForOSR);
+      Retry(kTooManySpillSlotsNeededForOSR);
       spill_index = 0;
     }
   }
index 55c599451b406a21c1e9f67536c900026f6d5af5..30b994ee77debed5f97759f7217d270107a83d9b 100644 (file)
@@ -2749,17 +2749,11 @@ class LPlatformChunk FINAL : public LChunk {
 class LChunkBuilder FINAL : public LChunkBuilderBase {
  public:
   LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator)
-      : LChunkBuilderBase(graph->zone()),
-        chunk_(NULL),
-        info_(info),
-        graph_(graph),
-        status_(UNUSED),
+      : LChunkBuilderBase(info, graph),
         current_instruction_(NULL),
         current_block_(NULL),
         next_block_(NULL),
-        allocator_(allocator) { }
-
-  Isolate* isolate() const { return graph_->isolate(); }
+        allocator_(allocator) {}
 
   // Build the sequence for the graph.
   LPlatformChunk* Build();
@@ -2789,24 +2783,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
   LInstruction* DoFlooringDivI(HMathFloorOfDiv* instr);
 
  private:
-  enum Status {
-    UNUSED,
-    BUILDING,
-    DONE,
-    ABORTED
-  };
-
-  LPlatformChunk* chunk() const { return chunk_; }
-  CompilationInfo* info() const { return info_; }
-  HGraph* graph() const { return graph_; }
-
-  bool is_unused() const { return status_ == UNUSED; }
-  bool is_building() const { return status_ == BUILDING; }
-  bool is_done() const { return status_ == DONE; }
-  bool is_aborted() const { return status_ == ABORTED; }
-
-  void Abort(BailoutReason reason);
-
   // Methods for getting operands for Use / Define / Temp.
   LUnallocated* ToUnallocated(Register reg);
   LUnallocated* ToUnallocated(XMMRegister reg);
@@ -2898,10 +2874,6 @@ class LChunkBuilder FINAL : public LChunkBuilderBase {
                               HBinaryOperation* instr);
   void FindDehoistedKeyDefinitions(HValue* candidate);
 
-  LPlatformChunk* chunk_;
-  CompilationInfo* info_;
-  HGraph* const graph_;
-  Status status_;
   HInstruction* current_instruction_;
   HBasicBlock* current_block_;
   HBasicBlock* next_block_;
index 534811e0ef3a6b2b1d6b5a950f729a2c70d085e5..d051773b40240d13fcb795bb87365f99a729c374 100644 (file)
@@ -6,6 +6,7 @@
 #define V8_X64_MACRO_ASSEMBLER_X64_H_
 
 #include "src/assembler.h"
+#include "src/bailout-reason.h"
 #include "src/frames.h"
 #include "src/globals.h"
 
index 433312452c672688ff1288dd5fb06bea1f818efb..c63cd94c0ed86236b9fb28c144d8dd687ef2364e 100644 (file)
         '../../src/ast.h',
         '../../src/background-parsing-task.cc',
         '../../src/background-parsing-task.h',
+        '../../src/bailout-reason.cc',
+        '../../src/bailout-reason.h',
         '../../src/bignum-dtoa.cc',
         '../../src/bignum-dtoa.h',
         '../../src/bignum.cc',