Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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* IsSpecificClassOf(Arguments args, String* name) { | 224 inline static Object* IsSpecificClassOf(Arguments args, String* name) { |
|
Mads Ager (chromium)
2008/10/17 11:19:11
HasSpecificClass?
| |
| 225 NoHandleAllocation ha; | 225 NoHandleAllocation ha; |
| 226 ASSERT(args.length() == 1); | 226 ASSERT(args.length() == 1); |
| 227 Object* obj = args[0]; | 227 Object* obj = args[0]; |
| 228 if (obj->IsJSObject() && (JSObject::cast(obj)->class_name() == name)) { | 228 if (obj->IsJSObject() && (JSObject::cast(obj)->class_name() == name)) { |
| 229 return Heap::true_value(); | 229 return Heap::true_value(); |
| 230 } | 230 } |
| 231 return Heap::false_value(); | 231 return Heap::false_value(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 static Object* Runtime_IsStringClass(Arguments args) { | 234 static Object* Runtime_IsStringClass(Arguments args) { |
| 235 return IsSpecificClassOf(args, Heap::String_symbol()); | 235 return IsSpecificClassOf(args, Heap::String_symbol()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 static Object* Runtime_IsDateClass(Arguments args) { | 239 static Object* Runtime_IsDateClass(Arguments args) { |
| 240 return IsSpecificClassOf(args, Heap::Date_symbol()); | 240 return IsSpecificClassOf(args, Heap::Date_symbol()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 | 243 |
| 244 static Object* Runtime_IsArrayClass(Arguments args) { | 244 static Object* Runtime_IsArrayClass(Arguments args) { |
| 245 return IsSpecificClassOf(args, Heap::Array_symbol()); | 245 return IsSpecificClassOf(args, Heap::Array_symbol()); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 static Object* Runtime_IsFunctionClass(Arguments args) { | |
| 250 return IsSpecificClassOf(args, Heap::function_class_symbol()); | |
| 251 } | |
| 252 | |
| 253 | |
| 254 static Object* Runtime_IsNumberClass(Arguments args) { | |
| 255 return IsSpecificClassOf(args, Heap::Number_symbol()); | |
| 256 } | |
| 257 | |
| 258 | |
| 259 static Object* Runtime_IsBooleanClass(Arguments args) { | |
| 260 return IsSpecificClassOf(args, Heap::Boolean_symbol()); | |
| 261 } | |
| 262 | |
| 263 | |
| 264 static Object* Runtime_IsArgumentsClass(Arguments args) { | |
| 265 return IsSpecificClassOf(args, Heap::Arguments_symbol()); | |
| 266 } | |
| 267 | |
| 268 | |
| 249 static Object* Runtime_IsInPrototypeChain(Arguments args) { | 269 static Object* Runtime_IsInPrototypeChain(Arguments args) { |
| 250 NoHandleAllocation ha; | 270 NoHandleAllocation ha; |
| 251 ASSERT(args.length() == 2); | 271 ASSERT(args.length() == 2); |
| 252 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 272 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
| 253 Object* O = args[0]; | 273 Object* O = args[0]; |
| 254 Object* V = args[1]; | 274 Object* V = args[1]; |
| 255 while (true) { | 275 while (true) { |
| 256 Object* prototype = V->GetPrototype(); | 276 Object* prototype = V->GetPrototype(); |
| 257 if (prototype->IsNull()) return Heap::false_value(); | 277 if (prototype->IsNull()) return Heap::false_value(); |
| 258 if (O == prototype) return Heap::true_value(); | 278 if (O == prototype) return Heap::true_value(); |
| (...skipping 5144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5403 | 5423 |
| 5404 void Runtime::PerformGC(Object* result) { | 5424 void Runtime::PerformGC(Object* result) { |
| 5405 Failure* failure = Failure::cast(result); | 5425 Failure* failure = Failure::cast(result); |
| 5406 // Try to do a garbage collection; ignore it if it fails. The C | 5426 // Try to do a garbage collection; ignore it if it fails. The C |
| 5407 // entry stub will throw an out-of-memory exception in that case. | 5427 // entry stub will throw an out-of-memory exception in that case. |
| 5408 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); | 5428 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); |
| 5409 } | 5429 } |
| 5410 | 5430 |
| 5411 | 5431 |
| 5412 } } // namespace v8::internal | 5432 } } // namespace v8::internal |
| OLD | NEW |