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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 ASSERT(args.length() == 1); | 313 ASSERT(args.length() == 1); |
314 Object* arg = args[0]; | 314 Object* arg = args[0]; |
315 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 315 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
316 return Heap::ToBoolean(result); | 316 return Heap::ToBoolean(result); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 static Object* Runtime_GetTemplateField(Arguments args) { | 320 static Object* Runtime_GetTemplateField(Arguments args) { |
321 ASSERT(args.length() == 2); | 321 ASSERT(args.length() == 2); |
322 CONVERT_CHECKED(HeapObject, templ, args[0]); | 322 CONVERT_CHECKED(HeapObject, templ, args[0]); |
| 323 RUNTIME_ASSERT(templ->IsStruct()); |
323 CONVERT_CHECKED(Smi, field, args[1]); | 324 CONVERT_CHECKED(Smi, field, args[1]); |
324 int index = field->value(); | 325 return HeapObject::GetHeapObjectField(templ, field->value()); |
325 int offset = index * kPointerSize + HeapObject::kHeaderSize; | |
326 InstanceType type = templ->map()->instance_type(); | |
327 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | |
328 type == OBJECT_TEMPLATE_INFO_TYPE); | |
329 RUNTIME_ASSERT(offset > 0); | |
330 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | |
331 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | |
332 } else { | |
333 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | |
334 } | |
335 return HeapObject::RawField(templ, offset); | |
336 } | 326 } |
337 | 327 |
338 | 328 |
339 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) { | 329 static Object* ThrowRedeclarationError(const char* type, Handle<String> name) { |
340 HandleScope scope; | 330 HandleScope scope; |
341 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); | 331 Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type)); |
342 Handle<Object> args[2] = { type_handle, name }; | 332 Handle<Object> args[2] = { type_handle, name }; |
343 Handle<Object> error = | 333 Handle<Object> error = |
344 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); | 334 Factory::NewTypeError("redeclaration", HandleVector(args, 2)); |
345 return Top::Throw(*error); | 335 return Top::Throw(*error); |
(...skipping 5187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5533 | 5523 |
5534 void Runtime::PerformGC(Object* result) { | 5524 void Runtime::PerformGC(Object* result) { |
5535 Failure* failure = Failure::cast(result); | 5525 Failure* failure = Failure::cast(result); |
5536 // Try to do a garbage collection; ignore it if it fails. The C | 5526 // Try to do a garbage collection; ignore it if it fails. The C |
5537 // entry stub will throw an out-of-memory exception in that case. | 5527 // entry stub will throw an out-of-memory exception in that case. |
5538 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); | 5528 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); |
5539 } | 5529 } |
5540 | 5530 |
5541 | 5531 |
5542 } } // namespace v8::internal | 5532 } } // namespace v8::internal |
OLD | NEW |