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

Unified Diff: src/objects.cc

Issue 475423003: Implement Function.prototype.toMethod. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove stray change Created 6 years, 4 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/objects.h ('k') | src/property.h » ('j') | src/property.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 307bcbf13cdc539eaf041e835fa97910e0caa34c..1c2ecf040375e5b23b83e58571878be8c8407058 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9396,6 +9396,54 @@ void JSFunction::MarkInOptimizationQueue() {
}
+Handle<JSFunction> JSFunction::Copy(Handle<JSFunction> function) {
+ Isolate* isolate = function->GetIsolate();
+ Handle<Map> map(function->map());
+ Handle<SharedFunctionInfo> shared(function->shared());
+ Handle<Context> context(function->context());
+ Handle<JSFunction> clone =
+ isolate->factory()->NewFunctionWithMapFromSharedFunctionInfo(
+ map, shared, context);
+
+ if (shared->bound()) {
+ clone->set_function_bindings(function->function_bindings());
+ }
+
+ clone->set_properties(
arv (Not doing code reviews) 2014/08/20 15:35:53 For F.p.toMethod we should not copy the properties
+ *isolate->factory()->NewFixedArray(function->properties()->length()));
+
+ Handle<FixedArrayBase> original_elements(function->elements());
Toon Verwaest 2014/08/20 07:43:11 Use the ElementsAccessor Copy method instead.
+ if (original_elements->length() > 0) {
+ if (original_elements->IsFixedArray()) {
+ clone->set_elements(*isolate->factory()->CopyFixedArray(
+ Handle<FixedArray>::cast(original_elements)));
+ } else if (original_elements->IsFixedDoubleArray()) {
+ clone->set_elements(*isolate->factory()->CopyFixedDoubleArray(
+ Handle<FixedDoubleArray>::cast(original_elements)));
+ } else {
+ CHECK(false);
+ }
+ }
+
+
+ Handle<DescriptorArray> descriptors(map->instance_descriptors());
+ for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
+ Handle<Name> name(descriptors->GetKey(i));
+ PropertyDetails details(descriptors->GetDetails(i));
+ if (details.type() == NORMAL || details.type() == FIELD) {
Toon Verwaest 2014/08/20 07:43:11 NORMAL is not a valid entry for descriptors. Only
+ Handle<Object> value =
+ Object::GetProperty(function, name).ToHandleChecked();
+ JSObject::SetOwnPropertyIgnoreAttributes(
+ clone,
+ name,
+ value,
+ details.attributes()).Assert();
+ }
+ }
+ return clone;
+}
+
+
void SharedFunctionInfo::AddToOptimizedCodeMap(
Handle<SharedFunctionInfo> shared,
Handle<Context> native_context,
« no previous file with comments | « src/objects.h ('k') | src/property.h » ('j') | src/property.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698