OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 3060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3071 &if_keyisinvalid); | 3071 &if_keyisinvalid); |
3072 assembler->Bind(&if_keyispositivesmi); | 3072 assembler->Bind(&if_keyispositivesmi); |
3073 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, | 3073 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, |
3074 receiver, key); | 3074 receiver, key); |
3075 | 3075 |
3076 assembler->Bind(&if_keyisinvalid); | 3076 assembler->Bind(&if_keyisinvalid); |
3077 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, | 3077 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, |
3078 slot, vector); | 3078 slot, vector); |
3079 } | 3079 } |
3080 | 3080 |
3081 void FastCloneShallowObjectStub::GenerateAssembly( | |
3082 compiler::CodeStubAssembler* assembler) const { | |
3083 typedef compiler::CodeStubAssembler::Label Label; | |
3084 typedef compiler::Node Node; | |
3085 Label call_runtime(assembler); | |
3086 Node* closure = assembler->Parameter(0); | |
3087 Node* literals_index = assembler->Parameter(1); | |
3088 | |
3089 Node* undefined = assembler->UndefinedConstant(); | |
3090 Node* literals_array = | |
3091 assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset); | |
3092 Node* allocation_site = assembler->LoadFixedArrayElementSmiIndex( | |
3093 literals_array, literals_index, | |
3094 LiteralsArray::kFirstLiteralIndex * kPointerSize); | |
3095 Label if_isnotundefined(assembler); | |
3096 assembler->Branch(assembler->WordEqual(allocation_site, undefined), | |
Benedikt Meurer
2016/04/06 17:20:36
Use GotoIf.
| |
3097 &call_runtime, &if_isnotundefined); | |
3098 assembler->Bind(&if_isnotundefined); | |
3099 | |
3100 Node* boilerplate = assembler->LoadObjectField( | |
3101 allocation_site, AllocationSite::kTransitionInfoOffset); | |
3102 | |
3103 int length = this->length(); | |
3104 if (length == 0) { | |
3105 length = JSObject::kInitialGlobalObjectUnusedPropertiesCount; | |
3106 } | |
3107 int size = JSObject::kHeaderSize + length * kPointerSize; | |
3108 int object_size = size; | |
3109 if (FLAG_allocation_site_pretenuring) { | |
3110 size += AllocationMemento::kSize; | |
3111 } | |
3112 | |
3113 Node* boilerplate_map = assembler->LoadMap(boilerplate); | |
3114 Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map); | |
3115 Label if_sizeiscorrect(assembler); | |
3116 Node* size_in_words = | |
3117 assembler->Int32Constant(object_size >> kPointerSizeLog2); | |
3118 assembler->Branch(assembler->Word32Equal(instance_size, size_in_words), | |
Benedikt Meurer
2016/04/06 17:20:36
Use GotoIf.
| |
3119 &if_sizeiscorrect, &call_runtime); | |
3120 assembler->Bind(&if_sizeiscorrect); | |
3121 | |
3122 Node* copy = assembler->Allocate(size); | |
3123 | |
3124 for (int i = 0; i < size; i += kPointerSize) { | |
3125 // The Allocate above guarantees that the copy lies in new space. This | |
3126 // allows us to skip write barriers. This is necessary since we may also be | |
3127 // copying unboxed doubles. | |
3128 Node* field = | |
3129 assembler->LoadObjectField(boilerplate, i, MachineType::IntPtr()); | |
3130 assembler->StoreObjectFieldNoWriteBarrier( | |
3131 copy, i, field, MachineType::PointerRepresentation()); | |
3132 } | |
3133 | |
3134 if (FLAG_allocation_site_pretenuring) { | |
3135 Node* memento = assembler->InnerAllocate(copy, object_size); | |
3136 assembler->StoreObjectFieldNoWriteBarrier( | |
3137 memento, HeapObject::kMapOffset, | |
3138 assembler->LoadRoot(Heap::kAllocationMementoMapRootIndex)); | |
3139 assembler->StoreObjectFieldNoWriteBarrier( | |
3140 memento, AllocationMemento::kAllocationSiteOffset, allocation_site); | |
3141 Node* memento_create_count = assembler->LoadObjectField( | |
3142 allocation_site, AllocationSite::kPretenureCreateCountOffset); | |
3143 memento_create_count = assembler->SmiAdd( | |
3144 memento_create_count, assembler->SmiConstant(Smi::FromInt(1))); | |
3145 assembler->StoreObjectFieldNoWriteBarrier( | |
3146 allocation_site, AllocationSite::kPretenureCreateCountOffset, | |
3147 memento_create_count); | |
3148 } | |
3149 | |
3150 // TODO(verwaest): Allocate and fill in double boxes. | |
3151 assembler->Return(copy); | |
3152 | |
3153 assembler->Bind(&call_runtime); | |
3154 Node* constant_properties = assembler->Parameter(2); | |
3155 Node* flags = assembler->Parameter(3); | |
3156 Node* context = assembler->Parameter(4); | |
3157 assembler->TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure, | |
3158 literals_index, constant_properties, flags); | |
3159 } | |
3160 | |
3081 template<class StateType> | 3161 template<class StateType> |
3082 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | 3162 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
3083 // Note: Although a no-op transition is semantically OK, it is hinting at a | 3163 // Note: Although a no-op transition is semantically OK, it is hinting at a |
3084 // bug somewhere in our state transition machinery. | 3164 // bug somewhere in our state transition machinery. |
3085 DCHECK(from != to); | 3165 DCHECK(from != to); |
3086 if (!FLAG_trace_ic) return; | 3166 if (!FLAG_trace_ic) return; |
3087 OFStream os(stdout); | 3167 OFStream os(stdout); |
3088 os << "["; | 3168 os << "["; |
3089 PrintBaseName(os); | 3169 PrintBaseName(os); |
3090 os << ": " << from << "=>" << to << "]" << std::endl; | 3170 os << ": " << from << "=>" << to << "]" << std::endl; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3217 | 3297 |
3218 | 3298 |
3219 void FastCloneShallowArrayStub::InitializeDescriptor( | 3299 void FastCloneShallowArrayStub::InitializeDescriptor( |
3220 CodeStubDescriptor* descriptor) { | 3300 CodeStubDescriptor* descriptor) { |
3221 FastCloneShallowArrayDescriptor call_descriptor(isolate()); | 3301 FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
3222 descriptor->Initialize( | 3302 descriptor->Initialize( |
3223 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); | 3303 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); |
3224 } | 3304 } |
3225 | 3305 |
3226 | 3306 |
3227 void FastCloneShallowObjectStub::InitializeDescriptor( | |
3228 CodeStubDescriptor* descriptor) { | |
3229 FastCloneShallowObjectDescriptor call_descriptor(isolate()); | |
3230 descriptor->Initialize( | |
3231 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); | |
3232 } | |
3233 | |
3234 | |
3235 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3307 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3236 | 3308 |
3237 | 3309 |
3238 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3310 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3239 | 3311 |
3240 | 3312 |
3241 void RegExpConstructResultStub::InitializeDescriptor( | 3313 void RegExpConstructResultStub::InitializeDescriptor( |
3242 CodeStubDescriptor* descriptor) { | 3314 CodeStubDescriptor* descriptor) { |
3243 descriptor->Initialize( | 3315 descriptor->Initialize( |
3244 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | 3316 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3514 if (type->Is(Type::UntaggedPointer())) { | 3586 if (type->Is(Type::UntaggedPointer())) { |
3515 return Representation::External(); | 3587 return Representation::External(); |
3516 } | 3588 } |
3517 | 3589 |
3518 DCHECK(!type->Is(Type::Untagged())); | 3590 DCHECK(!type->Is(Type::Untagged())); |
3519 return Representation::Tagged(); | 3591 return Representation::Tagged(); |
3520 } | 3592 } |
3521 | 3593 |
3522 } // namespace internal | 3594 } // namespace internal |
3523 } // namespace v8 | 3595 } // namespace v8 |
OLD | NEW |