Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1385)

Unified Diff: src/code-stubs.cc

Issue 1838283003: Migrate FastCloneShallowObjectStub to TurboFan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 60b350cd93b22c702053057d0cbfb0bdf572e844..75594685a46ba7f1d85d853c2acf365dc24406c3 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -3078,6 +3078,86 @@ void LoadIndexedInterceptorStub::GenerateAssembly(
slot, vector);
}
+void FastCloneShallowObjectStub::GenerateAssembly(
+ compiler::CodeStubAssembler* assembler) const {
+ typedef compiler::CodeStubAssembler::Label Label;
+ typedef compiler::Node Node;
+ Label call_runtime(assembler);
+ Node* closure = assembler->Parameter(0);
+ Node* literals_index = assembler->Parameter(1);
+
+ Node* undefined = assembler->UndefinedConstant();
+ Node* literals_array =
+ assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset);
+ Node* allocation_site = assembler->LoadFixedArrayElementSmiIndex(
+ literals_array, literals_index,
+ LiteralsArray::kFirstLiteralIndex * kPointerSize);
+ Label if_isnotundefined(assembler);
+ assembler->Branch(assembler->WordEqual(allocation_site, undefined),
Benedikt Meurer 2016/04/06 17:20:36 Use GotoIf.
+ &call_runtime, &if_isnotundefined);
+ assembler->Bind(&if_isnotundefined);
+
+ Node* boilerplate = assembler->LoadObjectField(
+ allocation_site, AllocationSite::kTransitionInfoOffset);
+
+ int length = this->length();
+ if (length == 0) {
+ length = JSObject::kInitialGlobalObjectUnusedPropertiesCount;
+ }
+ int size = JSObject::kHeaderSize + length * kPointerSize;
+ int object_size = size;
+ if (FLAG_allocation_site_pretenuring) {
+ size += AllocationMemento::kSize;
+ }
+
+ Node* boilerplate_map = assembler->LoadMap(boilerplate);
+ Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map);
+ Label if_sizeiscorrect(assembler);
+ Node* size_in_words =
+ assembler->Int32Constant(object_size >> kPointerSizeLog2);
+ assembler->Branch(assembler->Word32Equal(instance_size, size_in_words),
Benedikt Meurer 2016/04/06 17:20:36 Use GotoIf.
+ &if_sizeiscorrect, &call_runtime);
+ assembler->Bind(&if_sizeiscorrect);
+
+ Node* copy = assembler->Allocate(size);
+
+ for (int i = 0; i < size; i += kPointerSize) {
+ // The Allocate above guarantees that the copy lies in new space. This
+ // allows us to skip write barriers. This is necessary since we may also be
+ // copying unboxed doubles.
+ Node* field =
+ assembler->LoadObjectField(boilerplate, i, MachineType::IntPtr());
+ assembler->StoreObjectFieldNoWriteBarrier(
+ copy, i, field, MachineType::PointerRepresentation());
+ }
+
+ if (FLAG_allocation_site_pretenuring) {
+ Node* memento = assembler->InnerAllocate(copy, object_size);
+ assembler->StoreObjectFieldNoWriteBarrier(
+ memento, HeapObject::kMapOffset,
+ assembler->LoadRoot(Heap::kAllocationMementoMapRootIndex));
+ assembler->StoreObjectFieldNoWriteBarrier(
+ memento, AllocationMemento::kAllocationSiteOffset, allocation_site);
+ Node* memento_create_count = assembler->LoadObjectField(
+ allocation_site, AllocationSite::kPretenureCreateCountOffset);
+ memento_create_count = assembler->SmiAdd(
+ memento_create_count, assembler->SmiConstant(Smi::FromInt(1)));
+ assembler->StoreObjectFieldNoWriteBarrier(
+ allocation_site, AllocationSite::kPretenureCreateCountOffset,
+ memento_create_count);
+ }
+
+ // TODO(verwaest): Allocate and fill in double boxes.
+ assembler->Return(copy);
+
+ assembler->Bind(&call_runtime);
+ Node* constant_properties = assembler->Parameter(2);
+ Node* flags = assembler->Parameter(3);
+ Node* context = assembler->Parameter(4);
+ assembler->TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure,
+ literals_index, constant_properties, flags);
+}
+
template<class StateType>
void HydrogenCodeStub::TraceTransition(StateType from, StateType to) {
// Note: Although a no-op transition is semantically OK, it is hinting at a
@@ -3224,14 +3304,6 @@ void FastCloneShallowArrayStub::InitializeDescriptor(
}
-void FastCloneShallowObjectStub::InitializeDescriptor(
- CodeStubDescriptor* descriptor) {
- FastCloneShallowObjectDescriptor call_descriptor(isolate());
- descriptor->Initialize(
- Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
-}
-
-
void CreateAllocationSiteStub::InitializeDescriptor(CodeStubDescriptor* d) {}

Powered by Google App Engine
This is Rietveld 408576698