// The initializer is constant if it is the zero-value of the
// variable's type or if the initial value is an immutable value
// that is not copied to the heap.
- Expression* init = var->init();
-
- // If we see "a = b; b = x", and x is a static
- // initializer, just set a to x.
- while (init != NULL && init->var_expression() != NULL)
- {
- Named_object* ino = init->var_expression()->named_object();
- if (!ino->is_variable() || ino->package() != NULL)
- break;
- Expression* ino_init = ino->var_value()->init();
- if (ino->var_value()->has_pre_init()
- || ino_init == NULL
- || !ino_init->is_static_initializer())
- break;
- init = ino_init;
- }
-
- bool is_static_initializer;
- if (init == NULL)
+ bool is_static_initializer = false;
+ if (var->init() == NULL)
is_static_initializer = true;
else
{
Type* var_type = var->type();
- init = Expression::make_cast(var_type, init, var->location());
- is_static_initializer = init->is_static_initializer();
+ Expression* init = var->init();
+ Expression* init_cast =
+ Expression::make_cast(var_type, init, var->location());
+ is_static_initializer = init_cast->is_static_initializer();
}
// Non-constant variable initializations might need to create
}
var_init_fn = init_fndecl;
}
-
- Bexpression* var_binit;
- if (init == NULL)
- var_binit = NULL;
- else
- {
- Translate_context context(this, var_init_fn, NULL, NULL);
- var_binit = init->get_backend(&context);
- }
+ Bexpression* var_binit = var->get_init(this, var_init_fn);
if (var_binit == NULL)
;
//
// We alias maxOffAddr just to make it clear that this is the maximum address
// for the page allocator's search space. See maxOffAddr for details.
-var maxSearchAddr = maxOffAddr
+func maxSearchAddr() offAddr {
+ return maxOffAddr
+}
// Global chunk index.
//
p.sysInit()
// Start with the searchAddr in a state indicating there's no free memory.
- p.searchAddr = maxSearchAddr
+ p.searchAddr = maxSearchAddr()
// Set the mheapLock.
p.mheapLock = mheapLock
// Initialize scavenge tracking state.
- p.scav.scavLWM = maxSearchAddr
+ p.scav.scavLWM = maxSearchAddr()
}
// tryChunkOf returns the bitmap data for the given chunk.
}
if l == 0 {
// We're at level zero, so that means we've exhausted our search.
- return 0, maxSearchAddr
+ return 0, maxSearchAddr()
}
// We're not at level zero, and we exhausted the level we were looking in.
// exhausted. Otherwise, the heap still might have free
// space in it, just not enough contiguous space to
// accommodate npages.
- p.searchAddr = maxSearchAddr
+ p.searchAddr = maxSearchAddr()
}
return 0, 0
}