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 3198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3209 &if_keyisinvalid); | 3209 &if_keyisinvalid); |
3210 assembler->Bind(&if_keyispositivesmi); | 3210 assembler->Bind(&if_keyispositivesmi); |
3211 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, | 3211 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, |
3212 receiver, key); | 3212 receiver, key); |
3213 | 3213 |
3214 assembler->Bind(&if_keyisinvalid); | 3214 assembler->Bind(&if_keyisinvalid); |
3215 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, | 3215 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, |
3216 slot, vector); | 3216 slot, vector); |
3217 } | 3217 } |
3218 | 3218 |
3219 void FastCloneShallowObjectStub::GenerateAssembly( | |
3220 compiler::CodeStubAssembler* assembler) const { | |
3221 typedef compiler::CodeStubAssembler::Label Label; | |
3222 typedef compiler::Node Node; | |
3223 Label call_runtime(assembler); | |
3224 Node* closure = assembler->Parameter(0); | |
3225 Node* literals_index = assembler->Parameter(1); | |
3226 | |
3227 Node* undefined = assembler->UndefinedConstant(); | |
3228 Node* literals_array = | |
3229 assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset); | |
3230 Node* allocation_site = assembler->LoadFixedArrayElementSmiIndex( | |
3231 literals_array, literals_index, | |
3232 LiteralsArray::kFirstLiteralIndex * kPointerSize); | |
3233 assembler->GotoIf(assembler->WordEqual(allocation_site, undefined), | |
3234 &call_runtime); | |
3235 | |
3236 Node* boilerplate = assembler->LoadObjectField( | |
3237 allocation_site, AllocationSite::kTransitionInfoOffset); | |
3238 | |
3239 int length = this->length(); | |
3240 if (length == 0) { | |
3241 length = JSObject::kInitialGlobalObjectUnusedPropertiesCount; | |
3242 } | |
3243 int size = JSObject::kHeaderSize + length * kPointerSize; | |
3244 int object_size = size; | |
3245 if (FLAG_allocation_site_pretenuring) { | |
3246 size += AllocationMemento::kSize; | |
3247 } | |
3248 | |
3249 Node* boilerplate_map = assembler->LoadMap(boilerplate); | |
3250 Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map); | |
3251 Node* size_in_words = | |
3252 assembler->Int32Constant(object_size >> kPointerSizeLog2); | |
3253 assembler->GotoUnless(assembler->Word32Equal(instance_size, size_in_words), | |
3254 &call_runtime); | |
3255 | |
3256 Node* copy = assembler->Allocate(size); | |
3257 | |
3258 for (int i = 0; i < size; i += kPointerSize) { | |
3259 // The Allocate above guarantees that the copy lies in new space. This | |
3260 // allows us to skip write barriers. This is necessary since we may also be | |
3261 // copying unboxed doubles. | |
3262 Node* field = | |
3263 assembler->LoadObjectField(boilerplate, i, MachineType::IntPtr()); | |
3264 assembler->StoreObjectFieldNoWriteBarrier( | |
3265 copy, i, field, MachineType::PointerRepresentation()); | |
3266 } | |
3267 | |
3268 if (FLAG_allocation_site_pretenuring) { | |
3269 Node* memento = assembler->InnerAllocate(copy, object_size); | |
3270 assembler->StoreObjectFieldNoWriteBarrier( | |
3271 memento, HeapObject::kMapOffset, | |
3272 assembler->LoadRoot(Heap::kAllocationMementoMapRootIndex)); | |
3273 assembler->StoreObjectFieldNoWriteBarrier( | |
3274 memento, AllocationMemento::kAllocationSiteOffset, allocation_site); | |
3275 Node* memento_create_count = assembler->LoadObjectField( | |
3276 allocation_site, AllocationSite::kPretenureCreateCountOffset); | |
3277 memento_create_count = assembler->SmiAdd( | |
3278 memento_create_count, assembler->SmiConstant(Smi::FromInt(1))); | |
3279 assembler->StoreObjectFieldNoWriteBarrier( | |
3280 allocation_site, AllocationSite::kPretenureCreateCountOffset, | |
3281 memento_create_count); | |
3282 } | |
3283 | |
3284 // TODO(verwaest): Allocate and fill in double boxes. | |
3285 assembler->Return(copy); | |
3286 | |
3287 assembler->Bind(&call_runtime); | |
3288 Node* constant_properties = assembler->Parameter(2); | |
3289 Node* flags = assembler->Parameter(3); | |
3290 Node* context = assembler->Parameter(4); | |
3291 assembler->TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure, | |
3292 literals_index, constant_properties, flags); | |
3293 } | |
3294 | |
3295 template<class StateType> | 3219 template<class StateType> |
3296 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | 3220 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
3297 // Note: Although a no-op transition is semantically OK, it is hinting at a | 3221 // Note: Although a no-op transition is semantically OK, it is hinting at a |
3298 // bug somewhere in our state transition machinery. | 3222 // bug somewhere in our state transition machinery. |
3299 DCHECK(from != to); | 3223 DCHECK(from != to); |
3300 if (!FLAG_trace_ic) return; | 3224 if (!FLAG_trace_ic) return; |
3301 OFStream os(stdout); | 3225 OFStream os(stdout); |
3302 os << "["; | 3226 os << "["; |
3303 PrintBaseName(os); | 3227 PrintBaseName(os); |
3304 os << ": " << from << "=>" << to << "]" << std::endl; | 3228 os << ": " << from << "=>" << to << "]" << std::endl; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3431 | 3355 |
3432 | 3356 |
3433 void FastCloneShallowArrayStub::InitializeDescriptor( | 3357 void FastCloneShallowArrayStub::InitializeDescriptor( |
3434 CodeStubDescriptor* descriptor) { | 3358 CodeStubDescriptor* descriptor) { |
3435 FastCloneShallowArrayDescriptor call_descriptor(isolate()); | 3359 FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
3436 descriptor->Initialize( | 3360 descriptor->Initialize( |
3437 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); | 3361 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); |
3438 } | 3362 } |
3439 | 3363 |
3440 | 3364 |
| 3365 void FastCloneShallowObjectStub::InitializeDescriptor( |
| 3366 CodeStubDescriptor* descriptor) { |
| 3367 FastCloneShallowObjectDescriptor call_descriptor(isolate()); |
| 3368 descriptor->Initialize( |
| 3369 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); |
| 3370 } |
| 3371 |
| 3372 |
3441 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3373 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3442 | 3374 |
3443 | 3375 |
3444 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3376 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3445 | 3377 |
3446 | 3378 |
3447 void RegExpConstructResultStub::InitializeDescriptor( | 3379 void RegExpConstructResultStub::InitializeDescriptor( |
3448 CodeStubDescriptor* descriptor) { | 3380 CodeStubDescriptor* descriptor) { |
3449 descriptor->Initialize( | 3381 descriptor->Initialize( |
3450 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | 3382 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3720 if (type->Is(Type::UntaggedPointer())) { | 3652 if (type->Is(Type::UntaggedPointer())) { |
3721 return Representation::External(); | 3653 return Representation::External(); |
3722 } | 3654 } |
3723 | 3655 |
3724 DCHECK(!type->Is(Type::Untagged())); | 3656 DCHECK(!type->Is(Type::Untagged())); |
3725 return Representation::Tagged(); | 3657 return Representation::Tagged(); |
3726 } | 3658 } |
3727 | 3659 |
3728 } // namespace internal | 3660 } // namespace internal |
3729 } // namespace v8 | 3661 } // namespace v8 |
OLD | NEW |