diff options
Diffstat (limited to 'deps/v8/src/code-stubs.cc')
-rw-r--r-- | deps/v8/src/code-stubs.cc | 132 |
1 files changed, 99 insertions, 33 deletions
diff --git a/deps/v8/src/code-stubs.cc b/deps/v8/src/code-stubs.cc index 21d11a93d0..bcc1fe8801 100644 --- a/deps/v8/src/code-stubs.cc +++ b/deps/v8/src/code-stubs.cc @@ -13,6 +13,7 @@ #include "src/ic/handler-compiler.h" #include "src/ic/ic.h" #include "src/macro-assembler.h" +#include "src/parser.h" namespace v8 { namespace internal { @@ -122,7 +123,6 @@ Handle<Code> PlatformCodeStub::GenerateCode() { // Create the code object. CodeDesc desc; masm.GetCode(&desc); - // Copy the generated code into a heap object. Code::Flags flags = Code::ComputeFlags( GetCodeKind(), @@ -268,8 +268,7 @@ MaybeHandle<Code> CodeStub::GetCode(Isolate* isolate, uint32_t key) { void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { // Generate the uninitialized versions of the stub. for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { - BinaryOpICStub stub(isolate, static_cast<Token::Value>(op), - LanguageMode::SLOPPY); + BinaryOpICStub stub(isolate, static_cast<Token::Value>(op), Strength::WEAK); stub.GetCode(); } @@ -314,18 +313,29 @@ void BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime( } -void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT - os << "StringAddStub"; - if ((flags() & STRING_ADD_CHECK_BOTH) == STRING_ADD_CHECK_BOTH) { - os << "_CheckBoth"; - } else if ((flags() & STRING_ADD_CHECK_LEFT) == STRING_ADD_CHECK_LEFT) { - os << "_CheckLeft"; - } else if ((flags() & STRING_ADD_CHECK_RIGHT) == STRING_ADD_CHECK_RIGHT) { - os << "_CheckRight"; - } - if (pretenure_flag() == TENURED) { - os << "_Tenured"; +std::ostream& operator<<(std::ostream& os, const StringAddFlags& flags) { + switch (flags) { + case STRING_ADD_CHECK_NONE: + return os << "CheckNone"; + case STRING_ADD_CHECK_LEFT: + return os << "CheckLeft"; + case STRING_ADD_CHECK_RIGHT: + return os << "CheckRight"; + case STRING_ADD_CHECK_BOTH: + return os << "CheckBoth"; } + UNREACHABLE(); + return os; +} + + +void StringAddStub::PrintBaseName(std::ostream& os) const { // NOLINT + os << "StringAddStub_" << flags() << "_" << pretenure_flag(); +} + + +void StringAddTFStub::PrintBaseName(std::ostream& os) const { // NOLINT + os << "StringAddTFStub_" << flags() << "_" << pretenure_flag(); } @@ -453,6 +463,50 @@ void CompareNilICStub::UpdateStatus(Handle<Object> object) { } +namespace { + +Handle<JSFunction> GetFunction(Isolate* isolate, const char* name) { + v8::ExtensionConfiguration no_extensions; + Handle<Context> ctx = isolate->bootstrapper()->CreateEnvironment( + MaybeHandle<JSGlobalProxy>(), v8::Local<v8::ObjectTemplate>(), + &no_extensions); + Handle<JSBuiltinsObject> builtins = handle(ctx->builtins()); + MaybeHandle<Object> fun = Object::GetProperty(isolate, builtins, name); + Handle<JSFunction> function = Handle<JSFunction>::cast(fun.ToHandleChecked()); + DCHECK(!function->IsUndefined() && + "JavaScript implementation of stub not found"); + return function; +} +} // namespace + + +Handle<Code> TurboFanCodeStub::GenerateCode() { + // Get the outer ("stub generator") function. + const char* name = CodeStub::MajorName(MajorKey(), false); + Handle<JSFunction> outer = GetFunction(isolate(), name); + DCHECK_EQ(2, outer->shared()->length()); + + // Invoke the outer function to get the stub itself. + Factory* factory = isolate()->factory(); + Handle<Object> call_conv = factory->InternalizeUtf8String(name); + Handle<Object> minor_key = factory->NewNumber(MinorKey()); + Handle<Object> args[] = {call_conv, minor_key}; + MaybeHandle<Object> result = Execution::Call( + isolate(), outer, factory->undefined_value(), 2, args, false); + Handle<JSFunction> inner = Handle<JSFunction>::cast(result.ToHandleChecked()); + // Just to make sure nobody calls this... + inner->set_code(isolate()->builtins()->builtin(Builtins::kIllegal)); + + Zone zone; + // Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair. + ParseInfo parse_info(&zone, inner); + CompilationInfo info(&parse_info); + info.SetFunctionType(GetCallInterfaceDescriptor().GetFunctionType()); + info.SetStub(this); + return info.GenerateCodeStub(); +} + + template<class StateType> void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { // Note: Although a no-op transition is semantically OK, it is hinting at a @@ -564,11 +618,6 @@ void JSEntryStub::FinishCode(Handle<Code> code) { } -void LoadFastElementStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { - descriptor->Initialize(FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); -} - - void LoadDictionaryElementStub::InitializeDescriptor( CodeStubDescriptor* descriptor) { descriptor->Initialize(FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); @@ -578,7 +627,9 @@ void LoadDictionaryElementStub::InitializeDescriptor( void KeyedLoadGenericStub::InitializeDescriptor( CodeStubDescriptor* descriptor) { descriptor->Initialize( - Runtime::FunctionForId(Runtime::kKeyedGetProperty)->entry); + Runtime::FunctionForId(is_strong(language_mode()) + ? Runtime::kKeyedGetPropertyStrong + : Runtime::kKeyedGetProperty)->entry); } @@ -587,18 +638,17 @@ void HandlerStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { descriptor->Initialize(FUNCTION_ADDR(StoreIC_MissFromStubFailure)); } else if (kind() == Code::KEYED_LOAD_IC) { descriptor->Initialize(FUNCTION_ADDR(KeyedLoadIC_MissFromStubFailure)); + } else if (kind() == Code::KEYED_STORE_IC) { + descriptor->Initialize(FUNCTION_ADDR(KeyedStoreIC_MissFromStubFailure)); } } -CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() { +CallInterfaceDescriptor HandlerStub::GetCallInterfaceDescriptor() const { if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) { - if (FLAG_vector_ics) { - return VectorLoadICDescriptor(isolate()); - } - return LoadDescriptor(isolate()); + return LoadWithVectorDescriptor(isolate()); } else { - DCHECK_EQ(Code::STORE_IC, kind()); + DCHECK(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC); return StoreDescriptor(isolate()); } } @@ -616,14 +666,12 @@ void ElementsTransitionAndStoreStub::InitializeDescriptor( } -CallInterfaceDescriptor StoreTransitionStub::GetCallInterfaceDescriptor() { +CallInterfaceDescriptor StoreTransitionStub::GetCallInterfaceDescriptor() + const { return StoreTransitionDescriptor(isolate()); } -void MegamorphicLoadStub::InitializeDescriptor(CodeStubDescriptor* d) {} - - void FastNewClosureStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { descriptor->Initialize( Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); @@ -762,7 +810,8 @@ void StoreElementStub::Generate(MacroAssembler* masm) { case DICTIONARY_ELEMENTS: ElementHandlerCompiler::GenerateStoreSlow(masm); break; - case SLOPPY_ARGUMENTS_ELEMENTS: + case FAST_SLOPPY_ARGUMENTS_ELEMENTS: + case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: UNREACHABLE(); break; } @@ -879,7 +928,7 @@ bool ToBooleanStub::UpdateStatus(Handle<Object> object) { Types old_types = new_types; bool to_boolean_value = new_types.UpdateStatus(object); TraceTransition(old_types, new_types); - set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToByte())); + set_sub_minor_key(TypesBits::update(sub_minor_key(), new_types.ToIntegral())); return to_boolean_value; } @@ -1001,4 +1050,21 @@ InternalArrayConstructorStub::InternalArrayConstructorStub( } -} } // namespace v8::internal +Representation RepresentationFromType(Type* type) { + if (type->Is(Type::UntaggedSigned()) || type->Is(Type::UntaggedUnsigned())) { + return Representation::Integer32(); + } + + if (type->Is(Type::TaggedSigned())) { + return Representation::Smi(); + } + + if (type->Is(Type::UntaggedPointer())) { + return Representation::External(); + } + + DCHECK(!type->Is(Type::Untagged())); + return Representation::Tagged(); +} +} // namespace internal +} // namespace v8 |