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 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3009 &if_keyisinvalid); | 3009 &if_keyisinvalid); |
3010 assembler->Bind(&if_keyispositivesmi); | 3010 assembler->Bind(&if_keyispositivesmi); |
3011 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, | 3011 assembler->TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, |
3012 receiver, key); | 3012 receiver, key); |
3013 | 3013 |
3014 assembler->Bind(&if_keyisinvalid); | 3014 assembler->Bind(&if_keyisinvalid); |
3015 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, | 3015 assembler->TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, |
3016 slot, vector); | 3016 slot, vector); |
3017 } | 3017 } |
3018 | 3018 |
3019 void FastCloneShallowObjectStub::GenerateAssembly( | |
3020 compiler::CodeStubAssembler* assembler) const { | |
3021 typedef compiler::CodeStubAssembler::Label Label; | |
3022 typedef compiler::Node Node; | |
3023 Label call_runtime(assembler); | |
3024 Node* closure = assembler->Parameter(0); | |
3025 Node* literals_index = assembler->Parameter(1); | |
3026 | |
3027 Node* undefined = assembler->UndefinedConstant(); | |
3028 Node* literals_array = | |
3029 assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset); | |
3030 Node* allocation_site = assembler->LoadFixedArrayElementSmiIndex( | |
3031 literals_array, literals_index, | |
3032 LiteralsArray::kFirstLiteralIndex * kPointerSize); | |
3033 Label if_isnotundefined(assembler); | |
3034 assembler->Branch(assembler->WordEqual(allocation_site, undefined), | |
3035 &call_runtime, &if_isnotundefined); | |
3036 assembler->Bind(&if_isnotundefined); | |
3037 | |
3038 Node* boilerplate = assembler->LoadObjectField( | |
3039 allocation_site, AllocationSite::kTransitionInfoOffset); | |
3040 | |
3041 int length = this->length(); | |
3042 if (length == 0) { | |
3043 length = JSObject::kInitialGlobalObjectUnusedPropertiesCount; | |
3044 } | |
3045 int size = JSObject::kHeaderSize + length * kPointerSize; | |
3046 | |
3047 Node* boilerplate_map = assembler->LoadMap(boilerplate); | |
3048 Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map); | |
3049 Label if_sizeiscorrect(assembler); | |
3050 Node* size_in_words = assembler->Int32Constant(size >> kPointerSizeLog2); | |
3051 assembler->Branch(assembler->Word32Equal(instance_size, size_in_words), | |
3052 &if_sizeiscorrect, &call_runtime); | |
3053 assembler->Bind(&if_sizeiscorrect); | |
3054 | |
3055 Node* copy = assembler->Allocate(size); | |
Toon Verwaest
2016/03/30 15:11:01
This trashes the context register if it calls the
Benedikt Meurer
2016/03/30 17:12:35
This is fine (and true for essentially all TurboFa
| |
3056 | |
3057 for (int i = 0; i < size; i += kPointerSize) { | |
3058 // The Allocate above guarantees that the copy lies in new space. This | |
3059 // allows us to skip write barriers. This is necessary since we may also be | |
3060 // copying unboxed doubles. | |
3061 Node* field = assembler->LoadObjectField(boilerplate, i); | |
Toon Verwaest
2016/03/30 15:11:01
I guess I should use a different load instruction
Benedikt Meurer
2016/03/30 17:12:35
Yes, something like LoadRawPointer/StoreRawPointer
| |
3062 assembler->StoreObjectFieldNoWriteBarrier(copy, i, field); | |
Toon Verwaest
2016/03/30 15:11:01
And probably the same for storing it...
| |
3063 } | |
3064 // TODO(verwaest): Allocate and fill in double boxes. | |
3065 assembler->Return(copy); | |
3066 | |
3067 assembler->Bind(&call_runtime); | |
3068 Node* constant_properties = assembler->Parameter(2); | |
3069 Node* flags = assembler->Parameter(3); | |
3070 Node* context = assembler->Parameter(4); | |
3071 assembler->TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure, | |
3072 literals_index, constant_properties, flags); | |
3073 } | |
3074 | |
3019 template<class StateType> | 3075 template<class StateType> |
3020 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { | 3076 void HydrogenCodeStub::TraceTransition(StateType from, StateType to) { |
3021 // Note: Although a no-op transition is semantically OK, it is hinting at a | 3077 // Note: Although a no-op transition is semantically OK, it is hinting at a |
3022 // bug somewhere in our state transition machinery. | 3078 // bug somewhere in our state transition machinery. |
3023 DCHECK(from != to); | 3079 DCHECK(from != to); |
3024 if (!FLAG_trace_ic) return; | 3080 if (!FLAG_trace_ic) return; |
3025 OFStream os(stdout); | 3081 OFStream os(stdout); |
3026 os << "["; | 3082 os << "["; |
3027 PrintBaseName(os); | 3083 PrintBaseName(os); |
3028 os << ": " << from << "=>" << to << "]" << std::endl; | 3084 os << ": " << from << "=>" << to << "]" << std::endl; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3155 | 3211 |
3156 | 3212 |
3157 void FastCloneShallowArrayStub::InitializeDescriptor( | 3213 void FastCloneShallowArrayStub::InitializeDescriptor( |
3158 CodeStubDescriptor* descriptor) { | 3214 CodeStubDescriptor* descriptor) { |
3159 FastCloneShallowArrayDescriptor call_descriptor(isolate()); | 3215 FastCloneShallowArrayDescriptor call_descriptor(isolate()); |
3160 descriptor->Initialize( | 3216 descriptor->Initialize( |
3161 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); | 3217 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry); |
3162 } | 3218 } |
3163 | 3219 |
3164 | 3220 |
3165 void FastCloneShallowObjectStub::InitializeDescriptor( | |
3166 CodeStubDescriptor* descriptor) { | |
3167 FastCloneShallowObjectDescriptor call_descriptor(isolate()); | |
3168 descriptor->Initialize( | |
3169 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); | |
3170 } | |
3171 | |
3172 | |
3173 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3221 void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3174 | 3222 |
3175 | 3223 |
3176 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 3224 void CreateWeakCellStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
3177 | 3225 |
3178 | 3226 |
3179 void RegExpConstructResultStub::InitializeDescriptor( | 3227 void RegExpConstructResultStub::InitializeDescriptor( |
3180 CodeStubDescriptor* descriptor) { | 3228 CodeStubDescriptor* descriptor) { |
3181 descriptor->Initialize( | 3229 descriptor->Initialize( |
3182 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | 3230 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3452 if (type->Is(Type::UntaggedPointer())) { | 3500 if (type->Is(Type::UntaggedPointer())) { |
3453 return Representation::External(); | 3501 return Representation::External(); |
3454 } | 3502 } |
3455 | 3503 |
3456 DCHECK(!type->Is(Type::Untagged())); | 3504 DCHECK(!type->Is(Type::Untagged())); |
3457 return Representation::Tagged(); | 3505 return Representation::Tagged(); |
3458 } | 3506 } |
3459 | 3507 |
3460 } // namespace internal | 3508 } // namespace internal |
3461 } // namespace v8 | 3509 } // namespace v8 |
OLD | NEW |