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

Side by Side Diff: src/runtime.cc

Issue 7911: Various API changes (Closed)
Patch Set: "Various API changes Created 12 years, 1 month 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
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-api.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 215
216 static Object* Runtime_ClassOf(Arguments args) { 216 static Object* Runtime_ClassOf(Arguments args) {
217 NoHandleAllocation ha; 217 NoHandleAllocation ha;
218 ASSERT(args.length() == 1); 218 ASSERT(args.length() == 1);
219 Object* obj = args[0]; 219 Object* obj = args[0];
220 if (!obj->IsJSObject()) return Heap::null_value(); 220 if (!obj->IsJSObject()) return Heap::null_value();
221 return JSObject::cast(obj)->class_name(); 221 return JSObject::cast(obj)->class_name();
222 } 222 }
223 223
224 inline static Object* HasSpecificClassOf(Arguments args, String* name) {
225 NoHandleAllocation ha;
226 ASSERT(args.length() == 1);
227 Object* obj = args[0];
228 if (obj->IsJSObject() && (JSObject::cast(obj)->class_name() == name)) {
229 return Heap::true_value();
230 }
231 return Heap::false_value();
232 }
233 224
234 static Object* Runtime_HasStringClass(Arguments args) { 225 static Object* Runtime_HasStringClass(Arguments args) {
235 return HasSpecificClassOf(args, Heap::String_symbol()); 226 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::String_symbol()));
236 } 227 }
237 228
238 229
239 static Object* Runtime_HasDateClass(Arguments args) { 230 static Object* Runtime_HasDateClass(Arguments args) {
240 return HasSpecificClassOf(args, Heap::Date_symbol()); 231 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Date_symbol()));
241 } 232 }
242 233
243 234
244 static Object* Runtime_HasArrayClass(Arguments args) { 235 static Object* Runtime_HasArrayClass(Arguments args) {
245 return HasSpecificClassOf(args, Heap::Array_symbol()); 236 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Array_symbol()));
246 } 237 }
247 238
248 239
249 static Object* Runtime_HasFunctionClass(Arguments args) { 240 static Object* Runtime_HasFunctionClass(Arguments args) {
250 return HasSpecificClassOf(args, Heap::function_class_symbol()); 241 return Heap::ToBoolean(
242 args[0]->HasSpecificClassOf(Heap::function_class_symbol()));
251 } 243 }
252 244
253 245
254 static Object* Runtime_HasNumberClass(Arguments args) { 246 static Object* Runtime_HasNumberClass(Arguments args) {
255 return HasSpecificClassOf(args, Heap::Number_symbol()); 247 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Number_symbol()));
256 } 248 }
257 249
258 250
259 static Object* Runtime_HasBooleanClass(Arguments args) { 251 static Object* Runtime_HasBooleanClass(Arguments args) {
260 return HasSpecificClassOf(args, Heap::Boolean_symbol()); 252 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Boolean_symbol()));
261 } 253 }
262 254
263 255
264 static Object* Runtime_HasArgumentsClass(Arguments args) { 256 static Object* Runtime_HasArgumentsClass(Arguments args) {
265 return HasSpecificClassOf(args, Heap::Arguments_symbol()); 257 return Heap::ToBoolean(
258 args[0]->HasSpecificClassOf(Heap::Arguments_symbol()));
266 } 259 }
267 260
268 261
269 static Object* Runtime_HasRegExpClass(Arguments args) { 262 static Object* Runtime_HasRegExpClass(Arguments args) {
270 return HasSpecificClassOf(args, Heap::RegExp_symbol()); 263 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::RegExp_symbol()));
271 } 264 }
272 265
273 266
274 static Object* Runtime_IsInPrototypeChain(Arguments args) { 267 static Object* Runtime_IsInPrototypeChain(Arguments args) {
275 NoHandleAllocation ha; 268 NoHandleAllocation ha;
276 ASSERT(args.length() == 2); 269 ASSERT(args.length() == 2);
277 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). 270 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
278 Object* O = args[0]; 271 Object* O = args[0];
279 Object* V = args[1]; 272 Object* V = args[1];
280 while (true) { 273 while (true) {
(...skipping 5203 matching lines...) Expand 10 before | Expand all | Expand 10 after
5484 5477
5485 void Runtime::PerformGC(Object* result) { 5478 void Runtime::PerformGC(Object* result) {
5486 Failure* failure = Failure::cast(result); 5479 Failure* failure = Failure::cast(result);
5487 // Try to do a garbage collection; ignore it if it fails. The C 5480 // Try to do a garbage collection; ignore it if it fails. The C
5488 // entry stub will throw an out-of-memory exception in that case. 5481 // entry stub will throw an out-of-memory exception in that case.
5489 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); 5482 Heap::CollectGarbage(failure->requested(), failure->allocation_space());
5490 } 5483 }
5491 5484
5492 5485
5493 } } // namespace v8::internal 5486 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698