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

Unified Diff: src/runtime.cc

Issue 12114054: Supporting AllocationSiteInfo for Nested arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing a port compile failure Created 7 years, 9 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
« no previous file with comments | « src/runtime.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 12777e78a6d2278cb8aa3a2a0fe2abaca2218738..8d041e4150660a378679e95558f455a86b0dc246 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -138,16 +138,26 @@ namespace internal {
static_cast<LanguageMode>(args.smi_at(index));
-MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
- JSObject* boilerplate) {
+
+MUST_USE_RESULT MaybeObject* Runtime::DeepCopyBoilerplate(
+ Isolate* isolate,
+ JSObject* boilerplate,
+ AllocationSiteMode allocation_site_mode) {
StackLimitCheck check(isolate);
if (check.HasOverflowed()) return isolate->StackOverflow();
Heap* heap = isolate->heap();
Object* result;
- { MaybeObject* maybe_result = heap->CopyJSObject(boilerplate);
- if (!maybe_result->ToObject(&result)) return maybe_result;
+ MaybeObject* maybe_result;
+ if (allocation_site_mode == TRACK_ALLOCATION_SITE &&
+ boilerplate->ShouldTrackAllocationInfo()) {
+ maybe_result = heap->CopyJSObjectWithAllocationSite(boilerplate);
+ } else {
+ maybe_result = heap->CopyJSObject(boilerplate);
}
+
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+
JSObject* copy = JSObject::cast(result);
// Deep copy local properties.
@@ -157,7 +167,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
Object* value = properties->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
+ allocation_site_mode);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
properties->set(i, result);
@@ -168,7 +179,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
Object* value = copy->InObjectPropertyAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
+ allocation_site_mode);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
copy->InObjectPropertyAtPut(i, result);
@@ -194,7 +206,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object);
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(isolate, js_object,
+ allocation_site_mode);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
{ MaybeObject* maybe_result =
@@ -231,7 +244,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
{ MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
- js_object);
+ js_object,
+ allocation_site_mode);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
elements->set(i, result);
@@ -250,7 +264,8 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
{ MaybeObject* maybe_result = DeepCopyBoilerplate(isolate,
- js_object);
+ js_object,
+ allocation_site_mode);
if (!maybe_result->ToObject(&result)) return maybe_result;
}
element_dictionary->ValueAtPut(i, result);
@@ -585,6 +600,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
CONVERT_SMI_ARG_CHECKED(flags, 3);
bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
+ bool allocation_sites_allowed =
+ (flags & ObjectLiteral::kCreateAllocationSiteInfos) != 0;
+
+ AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
+ if (allocation_sites_allowed) {
+ allocation_site_mode = TRACK_ALLOCATION_SITE;
+ }
// Check if boilerplate exists. If not, create it first.
Handle<Object> boilerplate(literals->get(literals_index), isolate);
@@ -598,7 +620,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) {
// Update the functions literal and return the boilerplate.
literals->set(literals_index, *boilerplate);
}
- return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
+
+ return Runtime::DeepCopyBoilerplate(isolate,
+ JSObject::cast(*boilerplate),
+ allocation_site_mode);
}
@@ -611,6 +636,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
CONVERT_SMI_ARG_CHECKED(flags, 3);
bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0;
+ bool allocation_site_info_allowed =
+ (flags & ObjectLiteral::kCreateAllocationSiteInfos) != 0;
// Check if boilerplate exists. If not, create it first.
Handle<Object> boilerplate(literals->get(literals_index), isolate);
@@ -624,16 +651,32 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) {
// Update the functions literal and return the boilerplate.
literals->set(literals_index, *boilerplate);
}
- return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate));
+
+ JSObject* boilerplate_object = JSObject::cast(*boilerplate);
+ if (allocation_site_info_allowed &&
+ boilerplate_object->ShouldTrackAllocationInfo()) {
+ return isolate->heap()->CopyJSObjectWithAllocationSite(
+ boilerplate_object);
+ }
+
+ return isolate->heap()->CopyJSObject(boilerplate_object);
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
HandleScope scope(isolate);
- ASSERT(args.length() == 3);
+ ASSERT(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
CONVERT_SMI_ARG_CHECKED(literals_index, 1);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
+ CONVERT_SMI_ARG_CHECKED(flags, 3);
+ bool allocation_sites_allowed =
+ (flags & ArrayLiteral::kCreateAllocationSiteInfos) != 0;
+
+ AllocationSiteMode allocation_site_mode = DONT_TRACK_ALLOCATION_SITE;
+ if (allocation_sites_allowed) {
+ allocation_site_mode = TRACK_ALLOCATION_SITE;
+ }
// Check if boilerplate exists. If not, create it first.
Handle<Object> boilerplate(literals->get(literals_index), isolate);
@@ -645,16 +688,22 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) {
// Update the functions literal and return the boilerplate.
literals->set(literals_index, *boilerplate);
}
- return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate));
+
+ return Runtime::DeepCopyBoilerplate(isolate,
+ JSObject::cast(*boilerplate),
+ allocation_site_mode);
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
HandleScope scope(isolate);
- ASSERT(args.length() == 3);
+ ASSERT(args.length() == 4);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0);
CONVERT_SMI_ARG_CHECKED(literals_index, 1);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2);
+ CONVERT_SMI_ARG_CHECKED(flags, 3);
+ bool allocation_site_info_allowed =
+ ((flags & ArrayLiteral::kCreateAllocationSiteInfos) != 0);
// Check if boilerplate exists. If not, create it first.
Handle<Object> boilerplate(literals->get(literals_index), isolate);
@@ -672,8 +721,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) {
}
JSObject* boilerplate_object = JSObject::cast(*boilerplate);
- AllocationSiteMode mode = AllocationSiteInfo::GetMode(
- boilerplate_object->GetElementsKind());
+ bool create_info = allocation_site_info_allowed &&
+ boilerplate_object->ShouldTrackAllocationInfo();
+ AllocationSiteMode mode = create_info
+ ? TRACK_ALLOCATION_SITE
+ : DONT_TRACK_ALLOCATION_SITE;
if (mode == TRACK_ALLOCATION_SITE) {
return isolate->heap()->CopyJSObjectWithAllocationSite(boilerplate_object);
}
@@ -4479,11 +4531,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
ElementsKind transitioned_kind = IsFastHoleyElementsKind(elements_kind)
? FAST_HOLEY_DOUBLE_ELEMENTS
: FAST_DOUBLE_ELEMENTS;
- if (IsMoreGeneralElementsKindTransition(
- boilerplate_object->GetElementsKind(),
- transitioned_kind)) {
- JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
- }
JSObject::TransitionElementsKind(object, transitioned_kind);
ASSERT(IsFastDoubleElementsKind(object->GetElementsKind()));
FixedDoubleArray* double_array = FixedDoubleArray::cast(object->elements());
@@ -4496,11 +4543,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
? FAST_HOLEY_ELEMENTS
: FAST_ELEMENTS;
JSObject::TransitionElementsKind(object, transitioned_kind);
- if (IsMoreGeneralElementsKindTransition(
- boilerplate_object->GetElementsKind(),
- transitioned_kind)) {
- JSObject::TransitionElementsKind(boilerplate_object, transitioned_kind);
- }
FixedArray* object_array = FixedArray::cast(object->elements());
object_array->set(store_index, *value);
}
« no previous file with comments | « src/runtime.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698