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

Side by Side Diff: src/runtime.cc

Issue 149068: - Inlined the code for make simple cons strings.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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
« src/heap.cc ('K') | « src/heap.cc ('k') | src/top.h » ('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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "runtime.h" 43 #include "runtime.h"
44 #include "scopeinfo.h" 44 #include "scopeinfo.h"
45 #include "v8threads.h" 45 #include "v8threads.h"
46 #include "smart-pointer.h" 46 #include "smart-pointer.h"
47 #include "parser.h" 47 #include "parser.h"
48 48
49 namespace v8 { 49 namespace v8 {
50 namespace internal { 50 namespace internal {
51 51
52 52
53 #define RUNTIME_ASSERT(value) do { \ 53 #define RUNTIME_ASSERT(value) \
54 if (!(value)) return IllegalOperation(); \ 54 if (!(value)) return Top::ThrowIllegalOperation();
55 } while (false)
56 55
57 // Cast the given object to a value of the specified type and store 56 // Cast the given object to a value of the specified type and store
58 // it in a variable with the given name. If the object is not of the 57 // it in a variable with the given name. If the object is not of the
59 // expected type call IllegalOperation and return. 58 // expected type call IllegalOperation and return.
60 #define CONVERT_CHECKED(Type, name, obj) \ 59 #define CONVERT_CHECKED(Type, name, obj) \
61 RUNTIME_ASSERT(obj->Is##Type()); \ 60 RUNTIME_ASSERT(obj->Is##Type()); \
62 Type* name = Type::cast(obj); 61 Type* name = Type::cast(obj);
63 62
64 #define CONVERT_ARG_CHECKED(Type, name, index) \ 63 #define CONVERT_ARG_CHECKED(Type, name, index) \
65 RUNTIME_ASSERT(args[index]->Is##Type()); \ 64 RUNTIME_ASSERT(args[index]->Is##Type()); \
(...skipping 24 matching lines...) Expand all
90 // a variable of the specified type with the given name. If the 89 // a variable of the specified type with the given name. If the
91 // object is not a Number call IllegalOperation and return. 90 // object is not a Number call IllegalOperation and return.
92 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \ 91 #define CONVERT_NUMBER_CHECKED(type, name, Type, obj) \
93 RUNTIME_ASSERT(obj->IsNumber()); \ 92 RUNTIME_ASSERT(obj->IsNumber()); \
94 type name = NumberTo##Type(obj); 93 type name = NumberTo##Type(obj);
95 94
96 // Non-reentrant string buffer for efficient general use in this file. 95 // Non-reentrant string buffer for efficient general use in this file.
97 static StaticResource<StringInputBuffer> runtime_string_input_buffer; 96 static StaticResource<StringInputBuffer> runtime_string_input_buffer;
98 97
99 98
100 static Object* IllegalOperation() {
101 return Top::Throw(Heap::illegal_access_symbol());
102 }
103
104
105 static Object* DeepCopyBoilerplate(JSObject* boilerplate) { 99 static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
106 StackLimitCheck check; 100 StackLimitCheck check;
107 if (check.HasOverflowed()) return Top::StackOverflow(); 101 if (check.HasOverflowed()) return Top::StackOverflow();
108 102
109 Object* result = Heap::CopyJSObject(boilerplate); 103 Object* result = Heap::CopyJSObject(boilerplate);
110 if (result->IsFailure()) return result; 104 if (result->IsFailure()) return result;
111 JSObject* copy = JSObject::cast(result); 105 JSObject* copy = JSObject::cast(result);
112 106
113 // Deep copy local properties. 107 // Deep copy local properties.
114 if (copy->HasFastProperties()) { 108 if (copy->HasFastProperties()) {
(...skipping 3582 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 #endif 3691 #endif
3698 x = fmod(x, y); 3692 x = fmod(x, y);
3699 // NewNumberFromDouble may return a Smi instead of a Number object 3693 // NewNumberFromDouble may return a Smi instead of a Number object
3700 return Heap::NewNumberFromDouble(x); 3694 return Heap::NewNumberFromDouble(x);
3701 } 3695 }
3702 3696
3703 3697
3704 static Object* Runtime_StringAdd(Arguments args) { 3698 static Object* Runtime_StringAdd(Arguments args) {
3705 NoHandleAllocation ha; 3699 NoHandleAllocation ha;
3706 ASSERT(args.length() == 2); 3700 ASSERT(args.length() == 2);
3707
3708 CONVERT_CHECKED(String, str1, args[0]); 3701 CONVERT_CHECKED(String, str1, args[0]);
3709 CONVERT_CHECKED(String, str2, args[1]); 3702 CONVERT_CHECKED(String, str2, args[1]);
3710 int len1 = str1->length();
3711 int len2 = str2->length();
3712 if (len1 == 0) return str2;
3713 if (len2 == 0) return str1;
3714 int length_sum = len1 + len2;
3715 // Make sure that an out of memory exception is thrown if the length
3716 // of the new cons string is too large to fit in a Smi.
3717 if (length_sum > Smi::kMaxValue || length_sum < 0) {
3718 Top::context()->mark_out_of_memory();
3719 return Failure::OutOfMemoryException();
3720 }
3721 return Heap::AllocateConsString(str1, str2); 3703 return Heap::AllocateConsString(str1, str2);
3722 } 3704 }
3723 3705
3724 3706
3725 template<typename sinkchar> 3707 template<typename sinkchar>
3726 static inline void StringBuilderConcatHelper(String* special, 3708 static inline void StringBuilderConcatHelper(String* special,
3727 sinkchar* sink, 3709 sinkchar* sink,
3728 FixedArray* fixed_array, 3710 FixedArray* fixed_array,
3729 int array_length) { 3711 int array_length) {
3730 int position = 0; 3712 int position = 0;
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
4577 // extension object - introduced via eval. 4559 // extension object - introduced via eval.
4578 return top->global()->global_receiver(); 4560 return top->global()->global_receiver();
4579 } 4561 }
4580 4562
4581 4563
4582 static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) { 4564 static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) {
4583 HandleScope scope; 4565 HandleScope scope;
4584 ASSERT(args.length() == 2); 4566 ASSERT(args.length() == 2);
4585 4567
4586 if (!args[0]->IsContext() || !args[1]->IsString()) { 4568 if (!args[0]->IsContext() || !args[1]->IsString()) {
4587 return MakePair(IllegalOperation(), NULL); 4569 return MakePair(Top::ThrowIllegalOperation(), NULL);
4588 } 4570 }
4589 Handle<Context> context = args.at<Context>(0); 4571 Handle<Context> context = args.at<Context>(0);
4590 Handle<String> name = args.at<String>(1); 4572 Handle<String> name = args.at<String>(1);
4591 4573
4592 int index; 4574 int index;
4593 PropertyAttributes attributes; 4575 PropertyAttributes attributes;
4594 ContextLookupFlags flags = FOLLOW_CHAINS; 4576 ContextLookupFlags flags = FOLLOW_CHAINS;
4595 Handle<Object> holder = 4577 Handle<Object> holder =
4596 context->Lookup(name, flags, &index, &attributes); 4578 context->Lookup(name, flags, &index, &attributes);
4597 4579
(...skipping 2920 matching lines...) Expand 10 before | Expand all | Expand 10 after
7518 } else { 7500 } else {
7519 // Handle last resort GC and make sure to allow future allocations 7501 // Handle last resort GC and make sure to allow future allocations
7520 // to grow the heap without causing GCs (if possible). 7502 // to grow the heap without causing GCs (if possible).
7521 Counters::gc_last_resort_from_js.Increment(); 7503 Counters::gc_last_resort_from_js.Increment();
7522 Heap::CollectAllGarbage(); 7504 Heap::CollectAllGarbage();
7523 } 7505 }
7524 } 7506 }
7525 7507
7526 7508
7527 } } // namespace v8::internal 7509 } } // namespace v8::internal
OLDNEW
« src/heap.cc ('K') | « src/heap.cc ('k') | src/top.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698