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

Unified Diff: src/accessors.cc

Issue 19594002: Handlify JSFunction::SetPrototype method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Toon Verwaest. Created 7 years, 5 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/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index e441de47ee84289198ba5e368f517dfd91f89403..648f1135bc7f3f1fb2009a1b1cc46c821a59c70e 100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -450,26 +450,23 @@ Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) {
MaybeObject* Accessors::FunctionGetPrototype(Object* object, void*) {
Isolate* isolate = Isolate::Current();
- JSFunction* function = FindInstanceOf<JSFunction>(isolate, object);
- if (function == NULL) return isolate->heap()->undefined_value();
- while (!function->should_have_prototype()) {
- function = FindInstanceOf<JSFunction>(isolate, function->GetPrototype());
+ JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object);
+ if (function_raw == NULL) return isolate->heap()->undefined_value();
+ while (!function_raw->should_have_prototype()) {
+ function_raw = FindInstanceOf<JSFunction>(isolate,
+ function_raw->GetPrototype());
// There has to be one because we hit the getter.
- ASSERT(function != NULL);
+ ASSERT(function_raw != NULL);
}
- if (!function->has_prototype()) {
- Object* prototype;
- { MaybeObject* maybe_prototype
- = isolate->heap()->AllocateFunctionPrototype(function);
- if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
- }
- Object* result;
- { MaybeObject* maybe_result = function->SetPrototype(prototype);
- if (!maybe_result->ToObject(&result)) return maybe_result;
- }
+ if (!function_raw->has_prototype()) {
+ HandleScope scope(isolate);
+ Handle<JSFunction> function(function_raw);
+ Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
+ JSFunction::SetPrototype(function, proto);
+ function_raw = *function;
}
- return function->prototype();
+ return function_raw->prototype();
}
@@ -503,9 +500,7 @@ MaybeObject* Accessors::FunctionSetPrototype(JSObject* object,
old_value = isolate->factory()->NewFunctionPrototype(function);
}
- Handle<Object> result;
- MaybeObject* maybe_result = function->SetPrototype(*value);
- if (!maybe_result->ToHandle(&result, isolate)) return maybe_result;
+ JSFunction::SetPrototype(function, value);
ASSERT(function->prototype() == *value);
if (is_observed && !old_value->SameValue(*value)) {
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698