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

Side by Side Diff: src/objects.cc

Issue 7623011: Implement function proxies (except for their use as constructors). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed second round of comments. Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return CreateJSValue(global_context->boolean_function(), this); 78 return CreateJSValue(global_context->boolean_function(), this);
79 } else if (IsString()) { 79 } else if (IsString()) {
80 return CreateJSValue(global_context->string_function(), this); 80 return CreateJSValue(global_context->string_function(), this);
81 } 81 }
82 ASSERT(IsJSObject()); 82 ASSERT(IsJSObject());
83 return this; 83 return this;
84 } 84 }
85 85
86 86
87 MaybeObject* Object::ToObject() { 87 MaybeObject* Object::ToObject() {
88 if (IsJSObject()) { 88 if (IsJSReceiver()) {
89 return this; 89 return this;
90 } else if (IsNumber()) { 90 } else if (IsNumber()) {
91 Isolate* isolate = Isolate::Current(); 91 Isolate* isolate = Isolate::Current();
92 Context* global_context = isolate->context()->global_context(); 92 Context* global_context = isolate->context()->global_context();
93 return CreateJSValue(global_context->number_function(), this); 93 return CreateJSValue(global_context->number_function(), this);
94 } else if (IsBoolean()) { 94 } else if (IsBoolean()) {
95 Isolate* isolate = HeapObject::cast(this)->GetIsolate(); 95 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
96 Context* global_context = isolate->context()->global_context(); 96 Context* global_context = isolate->context()->global_context();
97 return CreateJSValue(global_context->boolean_function(), this); 97 return CreateJSValue(global_context->boolean_function(), this);
98 } else if (IsString()) { 98 } else if (IsString()) {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 if (!heap_object->IsJSObject()) { 621 if (!heap_object->IsJSObject()) {
622 Isolate* isolate = heap->isolate(); 622 Isolate* isolate = heap->isolate();
623 Context* global_context = isolate->context()->global_context(); 623 Context* global_context = isolate->context()->global_context();
624 if (heap_object->IsString()) { 624 if (heap_object->IsString()) {
625 holder = global_context->string_function()->instance_prototype(); 625 holder = global_context->string_function()->instance_prototype();
626 } else if (heap_object->IsHeapNumber()) { 626 } else if (heap_object->IsHeapNumber()) {
627 holder = global_context->number_function()->instance_prototype(); 627 holder = global_context->number_function()->instance_prototype();
628 } else if (heap_object->IsBoolean()) { 628 } else if (heap_object->IsBoolean()) {
629 holder = global_context->boolean_function()->instance_prototype(); 629 holder = global_context->boolean_function()->instance_prototype();
630 } else if (heap_object->IsJSProxy()) { 630 } else if (heap_object->IsJSProxy()) {
631 // TODO(rossberg): do something
631 return heap->undefined_value(); // For now... 632 return heap->undefined_value(); // For now...
632 } else { 633 } else {
633 // Undefined and null have no indexed properties. 634 // Undefined and null have no indexed properties.
634 ASSERT(heap_object->IsUndefined() || heap_object->IsNull()); 635 ASSERT(heap_object->IsUndefined() || heap_object->IsNull());
635 return heap->undefined_value(); 636 return heap->undefined_value();
636 } 637 }
637 } 638 }
638 } 639 }
639 640
640 // Inline the case for JSObjects. Doing so significantly improves the 641 // Inline the case for JSObjects. Doing so significantly improves the
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 accumulator->Add("<false>"); 1167 accumulator->Add("<false>");
1167 else 1168 else
1168 accumulator->Add("<Odd Oddball>"); 1169 accumulator->Add("<Odd Oddball>");
1169 break; 1170 break;
1170 } 1171 }
1171 case HEAP_NUMBER_TYPE: 1172 case HEAP_NUMBER_TYPE:
1172 accumulator->Add("<Number: "); 1173 accumulator->Add("<Number: ");
1173 HeapNumber::cast(this)->HeapNumberPrint(accumulator); 1174 HeapNumber::cast(this)->HeapNumberPrint(accumulator);
1174 accumulator->Put('>'); 1175 accumulator->Put('>');
1175 break; 1176 break;
1177 case JS_PROXY_TYPE:
1178 accumulator->Add("<JSProxy>");
1179 break;
1180 case JS_FUNCTION_PROXY_TYPE:
1181 accumulator->Add("<JSFunctionProxy>");
1182 break;
1176 case FOREIGN_TYPE: 1183 case FOREIGN_TYPE:
1177 accumulator->Add("<Foreign>"); 1184 accumulator->Add("<Foreign>");
1178 break; 1185 break;
1179 case JS_GLOBAL_PROPERTY_CELL_TYPE: 1186 case JS_GLOBAL_PROPERTY_CELL_TYPE:
1180 accumulator->Add("Cell for "); 1187 accumulator->Add("Cell for ");
1181 JSGlobalPropertyCell::cast(this)->value()->ShortPrint(accumulator); 1188 JSGlobalPropertyCell::cast(this)->value()->ShortPrint(accumulator);
1182 break; 1189 break;
1183 default: 1190 default:
1184 accumulator->Add("<Other heap object (%d)>", map()->instance_type()); 1191 accumulator->Add("<Other heap object (%d)>", map()->instance_type());
1185 break; 1192 break;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 case JS_FUNCTION_TYPE: 1248 case JS_FUNCTION_TYPE:
1242 reinterpret_cast<JSFunction*>(this) 1249 reinterpret_cast<JSFunction*>(this)
1243 ->JSFunctionIterateBody(object_size, v); 1250 ->JSFunctionIterateBody(object_size, v);
1244 break; 1251 break;
1245 case ODDBALL_TYPE: 1252 case ODDBALL_TYPE:
1246 Oddball::BodyDescriptor::IterateBody(this, v); 1253 Oddball::BodyDescriptor::IterateBody(this, v);
1247 break; 1254 break;
1248 case JS_PROXY_TYPE: 1255 case JS_PROXY_TYPE:
1249 JSProxy::BodyDescriptor::IterateBody(this, v); 1256 JSProxy::BodyDescriptor::IterateBody(this, v);
1250 break; 1257 break;
1258 case JS_FUNCTION_PROXY_TYPE:
1259 JSFunctionProxy::BodyDescriptor::IterateBody(this, v);
1260 break;
1251 case FOREIGN_TYPE: 1261 case FOREIGN_TYPE:
1252 reinterpret_cast<Foreign*>(this)->ForeignIterateBody(v); 1262 reinterpret_cast<Foreign*>(this)->ForeignIterateBody(v);
1253 break; 1263 break;
1254 case MAP_TYPE: 1264 case MAP_TYPE:
1255 Map::BodyDescriptor::IterateBody(this, v); 1265 Map::BodyDescriptor::IterateBody(this, v);
1256 break; 1266 break;
1257 case CODE_TYPE: 1267 case CODE_TYPE:
1258 reinterpret_cast<Code*>(this)->CodeIterateBody(v); 1268 reinterpret_cast<Code*>(this)->CodeIterateBody(v);
1259 break; 1269 break;
1260 case JS_GLOBAL_PROPERTY_CELL_TYPE: 1270 case JS_GLOBAL_PROPERTY_CELL_TYPE:
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 USE(result); 2372 USE(result);
2363 return NONE; 2373 return NONE;
2364 } 2374 }
2365 2375
2366 2376
2367 void JSProxy::Fix() { 2377 void JSProxy::Fix() {
2368 Isolate* isolate = GetIsolate(); 2378 Isolate* isolate = GetIsolate();
2369 HandleScope scope(isolate); 2379 HandleScope scope(isolate);
2370 Handle<JSProxy> self(this); 2380 Handle<JSProxy> self(this);
2371 2381
2372 isolate->factory()->BecomeJSObject(self); 2382 if (IsJSFunctionProxy()) {
2383 isolate->factory()->BecomeJSFunction(self);
2384 // Code will be set on the JavaScript side.
2385 } else {
2386 isolate->factory()->BecomeJSObject(self);
2387 }
2373 ASSERT(self->IsJSObject()); 2388 ASSERT(self->IsJSObject());
2374 // TODO(rossberg): recognize function proxies.
2375 } 2389 }
2376 2390
2377 2391
2378 2392
2379 MaybeObject* JSObject::SetPropertyForResult(LookupResult* result, 2393 MaybeObject* JSObject::SetPropertyForResult(LookupResult* result,
2380 String* name, 2394 String* name,
2381 Object* value, 2395 Object* value,
2382 PropertyAttributes attributes, 2396 PropertyAttributes attributes,
2383 StrictModeFlag strict_mode) { 2397 StrictModeFlag strict_mode) {
2384 Heap* heap = GetHeap(); 2398 Heap* heap = GetHeap();
(...skipping 9197 matching lines...) Expand 10 before | Expand all | Expand 10 after
11582 if (break_point_objects()->IsUndefined()) return 0; 11596 if (break_point_objects()->IsUndefined()) return 0;
11583 // Single break point. 11597 // Single break point.
11584 if (!break_point_objects()->IsFixedArray()) return 1; 11598 if (!break_point_objects()->IsFixedArray()) return 1;
11585 // Multiple break points. 11599 // Multiple break points.
11586 return FixedArray::cast(break_point_objects())->length(); 11600 return FixedArray::cast(break_point_objects())->length();
11587 } 11601 }
11588 #endif 11602 #endif
11589 11603
11590 11604
11591 } } // namespace v8::internal 11605 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698